i have a query which gets records from the database,
i need to pass ids in parameters to call this function,
like Myfunction(1, 2, 3)
i want to get the results which matching with this ids,
like
public List<Items> GetItems(int[] ids)
{
var a = from Items in db.item
where items.id == ids[]
select new Items
{
}
return a.ToList();
}
there is confusion on where clause ( how to get records regarding provided its)
i tried this with looping the ids but could not get any success
Thanks in Advance
You may use Contains, method to check. Something similar to Select * from table where Ids in (1,2,3,…)
Try the following.
Where
idsis your array.You may see: Creating IN Queries With Linq To Sql