Cómo pasar valores separados por comas a la consulta LINQ sin bucle for

I have list of values separated by commas, I need to pass these values to LINQ query and get matching values from DB, I have used for loop to solve this problem

aqui esta mi codigo

string drawingList="a,b,c,d";
string[] drawings = drawingList.Trim(',').Split(',');
IQueryable<table> filteredItems = null;
filteredItems =(some linq query)
List<table> filteredResult = new List<table>();
for (int i = 0; i < drawings.Count(); i++)
{
    dr = drawings[i].Trim();
    filteredItems = filteredItems.Where(p1 => p1.WorkItemNumber.Equals(dr));
                    filteredResult.AddRange(filteredItems);
}

How can I solve the above problem without the for loop

preguntado el 01 de febrero de 12 a las 03:02

2 Respuestas

Trata

filteredItems = filteredItems.Where(i => drawings.Contains(i => i.WorkItemNumber));

Respondido 01 Feb 12, 07:02

var result = from   drUntrimmed in drawings
               let  dr = drUntrimmed.Trim()
             from   f in filteredItems
             where  f.WorkItemNumber.Equals(dr)
             select f;

Respondido 01 Feb 12, 07:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.