Imports dGen.Library.Enums.QueryEnums.QueryOperatorEnum
Imports dGen.Library.Enums.QueryEnums.CompareEnum
Partial Class InstitucionDbHelper

#Region "Metodos Personalizados"
    ' Definir en esta region los metodos personalizados para el DbHelper


    Public Function GetListInstitucionesByEstado(ByVal idEstadoPlaza As String) As EntityList(Of Institucion)
        Dim QueryObject = CreateQueryObject()
        Dim sql As String = "select distinct i.* from Institucion as i, Dotacion.dbo.Plaza as p where p.idInstitucion=i.idInstitucion and (fechaInicioInscripcion <= GETDATE()) and (i.idInstitucion <> 'AA') and idConvocatoria<>'C1' and idEstadoPlaza in ("
        For Each id As Integer In idEstadoPlaza.Split(",")
            sql = String.Format("{0}{1},", sql, id)
        Next
        sql = sql.Substring(0, sql.Length - 1) + ") order by nombreInstitucion asc"

        QueryObject.CreateQuery(sql)

        Return QueryObject.ExecuteList()
    End Function

    Public Function GetTotalquePublican() As Integer
        Dim QueryObject = Me.CreateQueryObject
        QueryObject.CreateQuery("select count(distinct Institucion.idInstitucion) from Institucion, Dotacion.dbo.plaza where plaza.idInstitucion=Institucion.idInstitucion and idEstadoPlaza>1 and idConvocatoria<>'C1' and Institucion.idInstitucion<>'AA'")
        Return QueryObject.ExecuteScalar()
    End Function
#End Region
End Class
