[英]how to write linq query with where clause to get records between 9 am to 5 pm
[英]How do i write a linq query to get list of records where id in (1,2,3,8,23,45)
我想选择 n 个 id 的记录列表,我有 id 列表,我想在编写 sql 查询时立即使用它 select * from abc where id in(3,4,6,7,8, 14)。 像这样我想编写 linq 查询。 我写了这样的东西:
var mylist = (from log in context.mylog
where logIdList.Contains(log.Id)
select log).ToList();
但这给了我错误。
注意:logIdList 是 Id 列表。
你想要这样的东西:
var myList = from log in context.mylog
join id in logIdList on log.Id equals id
select log;
检查天气此解决方案是否有效。 我没试过。 所以不确定。
var MyList = Context.MyLog.Where(x => LogIdList.Contains(x.Id)).ToList();
希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.