我试过下面的LINQ查询在Linqer它工作正常,但它给下面的错误,而我用C#尝试
from IHeal_Mnt_Tickets in iHealEntities.iHeal_Mnt_Tickets
where
Tickets.Active == 1 &&
Tickets.MntID == 1 &&
Tickets.InsertedOn >= fromdate &&
Mnt_Tickets.InsertedOn <= todate &&
(new string[] { "Resolved", "Assigned" }).Contains(Tickets.status)
group Tickets by new {
Tickets.Instance
} into g
select new {
Instance = g.Key.Summus_Instance,
Assigned = (Int64?)g.Count(p => p.iHealID != null),
resolved = (System.Int64?)g.Sum(p => (p.status == "Resolved" ? 1 : 0)),
domain = (System.Int64?)g.Sum(p => (p.status == "Assigned" ? 1 : 0)),
iHeal_Closure = (Decimal?)Math.Round((Double)(Double)g.Sum(p => (p.iHeal_Cur_status == "Resolved" ? 1 : 0)) * 1.0 / (Double)g.Count(p => p.iHealID != null) * 100, 2, MidpointRounding.AwayFromZero)
};
错误的是
"LINQ to Entities does not recognize the method 'Double Round(Double, Int32, System.MidpointRounding)' method, and this method cannot be translated into a store expression."