public bool isLocked(BreakDownLogLock breakdownlock,string depotno)
{
int lockid = goContext
.goBreakDownLogLock
.Where(u => u.LogYear == breakdownlock.LogYear && u.LogMonth == breakdownlock.LogMonth
&& u.DepotNo in ( depotno)) // Not working Please help how to use IN clause
if (lockid > 0)
{
var breaklog = Context.goBreakDownLogLock.Find((lockid));
if (breaklog != null)
{
breaklog.isBreakLocked = true;
}
}
else
{
goContext.goBreakDownLogLock.Add(breakdownlock);
}
long cnt = goContext.SaveChanges();
return cnt;
}
As this is C# code you are rather testing if an enumeration contains a given value ie something such as:
int[] depotno = new int[]{1,2,3,4,5,6,7,8,9};
and in your LINQ query something such as ... && depotno.Contains(u.DepotNo) // will be translated on the SQL side to <column for u.DepotNo> IN (<list of array values>)
Member
410 Points
1326 Posts
How to use IN clause in Linq
Nov 19, 2019 10:05 AM|polachan|LINK
I want to use IN clause with LINQ please help
string depotno = '1,2,3,4,5,6,7,8,9'
All-Star
48490 Points
18071 Posts
Re: How to use IN clause in Linq
Nov 19, 2019 10:15 AM|PatriceSc|LINK
Hi,
As this is C# code you are rather testing if an enumeration contains a given value ie something such as:
int[] depotno = new int[]{1,2,3,4,5,6,7,8,9};
and in your LINQ query something such as ... && depotno.Contains(u.DepotNo) // will be translated on the SQL side to <column for u.DepotNo> IN (<list of array values>)
All-Star
58144 Points
15646 Posts
Re: How to use IN clause in Linq
Nov 19, 2019 05:55 PM|bruce (sqlwork.com)|LINK