Answers for "where in linq"

1

linq c# where condition

var query = MemberTable.Where(x=>x.sex.Equals(Sex))

if (members != null)
     query = query.Where(x=>members.Contains(x.membercode))

//use your query
query.ToList();
Posted by: Guest on June-19-2020
0

linq where c#

// The Where can be used to filter what you need, 
// if you want multiple items to be returned change 
// your variable to a list for example and replace FirstOrDefault with ToList
// For list of integers
List<int> myList = new List<int>(){1,2,3,4};
int singleItem = myList.Where(x => x == 1).FirstOrDefault();

// For list of custom object
List<CustomClassName> myList = new List<CustomClassName>()
{
  new CustomClassName(){ MyIntProp = 1, MyStringProp = "blah" },
  new CustomClassName(){ MyIntProp = 2, MyStringProp = "blah2" },
};
CustomClassName singleItem = myList.Where(x => x.MyIntProp == 1).FirstOrDefault();
CustomClassName singleItemTwo = myList.Where(x => x.MyStringProp == "blah2").FirstOrDefault();
Posted by: Guest on June-07-2021
0

where in linq

dataSource.StateList.Where(s => countryCodes.Contains(s.CountryCode))
Posted by: Guest on June-30-2021
-1

linq where c#

linq in c#
Posted by: Guest on May-14-2021
-1

linq c# or

filteredTasks = filteredTasks.Where(p => p.TaskStateID == 10 || 
                                         p.TaskStateID == 11 || 
                                         p.TaskStateID == 12);
Posted by: Guest on May-23-2020

Browse Popular Code Answers by Language