Entity framework core 为具有实体框架核心方法语法的组选择一条记录
在EntityFrameworkCore中,我需要使用方法语法来表示以下SQL查询 查询返回每个ProductID具有最高优先级的记录 有办法吗 谢谢。试试这个:Entity framework core 为具有实体框架核心方法语法的组选择一条记录,entity-framework-core,Entity Framework Core,在EntityFrameworkCore中,我需要使用方法语法来表示以下SQL查询 查询返回每个ProductID具有最高优先级的记录 有办法吗 谢谢。试试这个: var rules = db.Rules.Where( a=>db.Rules.Where( b => b.ProductId == a.ProductId && b.Priority > a.Priority ).Count() ==
var rules = db.Rules.Where(
a=>db.Rules.Where(
b => b.ProductId == a.ProductId && b.Priority > a.Priority
).Count() == 0
);
如果要使用Linq语法:
var rules = from a in db.Rules
where (
from b in db.Rules
where a.ProductId == b.ProductId
&& b.Priority > a.Priority
select b
).Count() == 0
select a;
试试这个:
var rules = db.Rules.Where(
a=>db.Rules.Where(
b => b.ProductId == a.ProductId && b.Priority > a.Priority
).Count() == 0
);
如果要使用Linq语法:
var rules = from a in db.Rules
where (
from b in db.Rules
where a.ProductId == b.ProductId
&& b.Priority > a.Priority
select b
).Count() == 0
select a;
我真的很想知道是谁和为什么否决了我的问题(没有留下评论,顺便说一句)我真的很想知道是谁和为什么否决了我的问题(没有留下评论,顺便说一句)