我有这个sql表达式,我想使用实体框架或linq将其转换为代码语法
select [Key],name from products where [Key] not in (select distinct parent from products where parent is not null)
试试这个,也许它可以帮助你
var p = products.Where(p => p.parent != null).select(p=>p.parent).Distinct();
var pro = products.Where(p => !p.Contains(p.Key))
.Select(p => new { ProKey = p.Key, ProName.Name });
也许它会起作用,但你仍然有问题让我知道......
我认为这会起作用。
var parents = products.Where(p => p.parent != null).Distinct();
var products = products.Where(p => !parents.Contains(p.Key))
.Select(p => new { p.Key, p.Name });