[英]How to use “AND” in Entity Framework under the same column
我一直在尋找一種從表中檢索某些特定信息的方法,但是它也沒有檢索任何結果,我正在使用Entity Framework和C#。
var plans = (
from p in context.AirTables
where p.eflID == 536 && p.eflID == 537
select p)
.ToList();
if (plans.Count() != 0)
給我0作為值,我100%確定我要檢索的信息是正確的。
有人可以幫我嗎?
提前致謝
您可能正在嘗試檢索在AirTables
列中eflID
536
或537
值的eflID
。 您可以通過幾種方式做到這一點。
int[] ids = new int[] { 536, 537};
var plans = context.AirTables.Where(x=> ids.Contains(x.eflID)).ToList();
要么
var plans = context.AirTables.Where(x=> x.eflID ==536 || x.eflID == 537).ToList();
第一個應轉換為... where eflID in (536, 537)
第二個應轉換為... where eflID in (536, 537)
... where eflID=536 OR eflID = 537
您需要使用OR
而不是And
檢查
var plans = context.AirTables.Where(x=> x.eflID ==536 || x.eflID == 537).ToList()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.