问题描述
晚上好。是否可以将多个IQueryable
合并为一个,而无需在Union
中使用EF Core 2
?主要问题在于它不允许使用.Union(),.Except()
等方法。
重要的是,IQueryable
应该作为单个查询执行。
这就是我想要得到的:toCreateSubquery.Union(toDeleteSubquery)
下面列出了我要合并的查询。
var toCreateSubquery =
validLinks
.Where(
rl => !existingLinks.Any(
el => el.Contract == rl.Contract && el.Estate == rl.Estate)) // Except() doesn't work'
.Select(x => new {x.Contract,x.Estate,Type = ActionType.Create});
var toDeleteSubquery =
existingLinks
.Where(el => !validLinks.Any(rl => el.Contract == rl.Contract && el.Estate == rl.Estate))
.Select(x => new {x.Contract,Type = ActionType.Delete});
This is the visualization是我要解决的问题。
我希望获得这些集合的并集而没有交集,并且能够区分属于这些集合之一。
以防万一,我附上了获得这些套装的代码:
var validLinks = from ac in _context.AreaContracts
from e in _context.Estate
where (from al in e.AreaLinks select al.Area.Id).Contains(ac.Area.Id) ||
e.Geometry.Intersects(
ac.Area.Geometry)
select new { Contract = ac.Contract.Id,Estate = e.Id };
var existingLinks = from sd in _context.Squaredistributions
select new { Contract = sd.Contract.Id,Estate = sd.Estate.Id };
感谢您的关注。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)