I am working on Entity frame work, i have created a method which is returning List of my Table,
I am retrieving data on base of grpID(which is foreign key, so i can have multiple records)
I have saved these grpID’s in an array so I want to run IN command on Entity framework so that i can get records in single List, How can i apply In command,my code is below
public List<tblResource> GetResources(long[] grpid)
{
try
{
return dataContext.tblResource.Where(c => c.GroupId == grpid && c.IsActive == true).ToList();//This code is not working as i am having array of groupIds
}
catch (Exception ex)
{
return ex;
}
}
You may use Contains to mimic something like
Select INquerywhere
grpidis your array of IDs.You may consider the following example. Suppose you have Product class with two properties ID and Name, and array of ProductList containing the IDs. The Select IN Query should be something like: