Contains in Linq with entity

Sometimes we require to use In or Not in operator in LINQ.

below is the example

   var setToRemove = "Approved,Rejected".Split(',');

                inv.StatusList = context.BindDropDown(fieldName: "SaneInv", pageName: "SaneInvoice").AsEnumerable().Where(i=>setToRemove.Contains(i.dmnValue_Text)).
                                      Select(x => new SelectListItem { Text = x.dmnValue_Text, Value = x.dmnValue_ID.ToString(), Selected = false }).ToList();

if tou want to use Not in use have to use ! operator before contains.

You Might Also Like

Leave a Reply