c# - Filter Generic List by multiple values -


is a general list of documents, how can I filter it by DOS ID 1 and 2?

I have tried the following link but it is not working. I need to filter the list and use it as a data source.

  list & lt; VisitDocs & gt; ListD = default (list & visit; Docs & gt;); Results = Dico in Docs from Docs in the Doc. DOSID == 1 & amp; Amp; Docs.DocID == 2docs; RptDocs.DataSource = listD;    

You should :

 < Code> results = list D. Where (Doctor => doc.DocID == 1 || doc.DocID == 2);  

or

  result = docs in the list where in the docs. DOSID == 1 || Docs. Choose dosid == 2 docs;  

Your DocID can be 1 or 2 , it can not be both. Your current status is & amp; Amp; which means that it should be 1 and 2 at the same time. To assign to Datasource call toList :

  rptDocs.DataSource = result.ToList ();  

Comments