I have been looking for a way to retrieve some specific information from a table but it's nor retrieving any result, I am using Entity Framework and C#.
var plans = (
from p in context.AirTables
where p.eflID == 536 && p.eflID == 537
select p)
.ToList();
The if (plans.Count() != 0)
is giving me 0 as value, and I am 100% sure that the information which I am retrieving is correct.
Can somebody help me out?
Thanks in advance
Your are probably trying to retrieve the AirTables
that cointain in the column eflID
either 536
or 537
values. You could do it in several ways.
int[] ids = new int[] { 536, 537};
var plans = context.AirTables.Where(x=> ids.Contains(x.eflID)).ToList();
or
var plans = context.AirTables.Where(x=> x.eflID ==536 || x.eflID == 537).ToList();
the first one should translate into ... where eflID in (536, 537)
and the second one into ... where eflID=536 OR eflID = 537
您需要使用OR
而不是And
检查
var plans = context.AirTables.Where(x=> x.eflID ==536 || x.eflID == 537).ToList()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.