我有这个工作的T-SQL语句,我想将它转换为LINQ。
---------- T-SQL ---------
select o.Type, o.Name, SUM(Price) As Total
from Transactions t
inner join Orders o
ON t.CustomerID = o.CustomerID
Group By o.Type, o.Name
Order by o.Name
-----我的尝试-----
from t in db.Transactions
join o in db.Orders on new { CustomerID = t.CustomerID } equals new { CustomerID = Convert.ToInt32(o.CustomerID) }
group o by new {
o.Type,
o.Name
} into g
orderby
g.Key.Name
select new {
g.Key.Type,
g.Key.Name,
Total = (int?)g.Sum(p => p.Price)
}
以上返回此错误:
LINQ to Entities无法识别方法'Int32 ToInt32(System.Object)'方法,并且此方法无法转换为商店表达式。
谢谢。