有人可以帮助我以正确的方式将此查询转换为Linq到实体查询。我对Linq相当陌生,想正确地编写这些查询。这是一个相当复杂的任务,它可以处理UNION及其子查询
SELECT pf.FileID, pf.ServerName, pf.MigrationType
FROM pOrders pf
WHERE pf.FileID IN (select GCMFileID FROM Signals
where SignalFileID = " + FileID + ")
UNION
SELECT pf.FileID, pf.ServerName, pf.MigrationType
FROM pOrders pf
WHERE pf.FileID = " + FileID + "
order by pf.MigrationType desc
最佳答案
我知道,我看到了评论...但是
var signalIds = Signals.Where(s => s.SignalFileId = FILEID).Select(x => x.GCMFileID ).ToArray();
pOrders.Where(pf => signalIds.Contains(pf.FileID))
.Union(
pOrders.Where(pf => pf.FileID == FILEID))
.OrderByDescending(u => u.MigrationType)
.Select(u => new {u.FileID, u.ServerName, u.MigrationType});
关于c# - 将联合查询转换为LINQ转换为实体查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10030415/