how to do a select count using Linq C #

1

I need to convert this snippet of SQL code to Linq C #. I've been able to convert almost all of the code.

SELECT COUNT(Q.ID_QUALIFICACAO) AS CONHEC_ESPECIFICO 
                        FROM QUALIFICACAO Q 
                        INNER JOIN 
                            ATENDIMENTO A ON Q.ID_QUALIFICACAO = A.ID_QUALIFICACAO AND 
                            Q.NOTACONHECESPECIF IN (9,10) AND 
                            A.ID_TERAPEUTA = 0 AND 
                            A.ATENDIMENTOREALIZADO = 1

Except for the line Q.NOTCONCONCONTROLLING IN (9,10)

The column NOTCONPECIF is integer type and I can not apply the Contains function to it.

What I've been able to produce so far is down:

 var numero = (from q in db.QUALIFICACAOs
                              join a in db.ATENDIMENTOes on q.ID_QUALIFICACAO equals a.ID_QUALIFICACAO
                              where  (q.NOTACONHECESPECIF == 10 || q.NOTACONHECESPECIF == 9) &&
                                     a.ID_TERAPEUTA == ID_TERAPEUTA &&
                                     a.ATENDIMENTOREALIZADO == true
                                     select new
                                          {
                                            q.NOTACONHECESPECIF
                                          }).Count();
    
asked by anonymous 02.11.2015 / 20:39

1 answer

1

Make an array with integer values:

var arraynota = new int[] { 9, 10};

var arraynota = (from q in db.QUALIFICACAOs
                              join a in db.ATENDIMENTOes on q.ID_QUALIFICACAO equals a.ID_QUALIFICACAO
                              where  (q.NOTACONHECESPECIF in arraynota) &&
                                     a.ID_TERAPEUTA == ID_TERAPEUTA &&
                                     a.ATENDIMENTOREALIZADO == true
                                     select new
                                          {
                                            q.NOTACONHECESPECIF
                                          }).Count();

I believe this will suit you.

    
02.11.2015 / 23:02