我有一张桌子。
create table tblCartItem(
pkCartItemId int primary key identity,
CartId int not null,
ProductId int not null,
Quantity int not null,
Price nvarchar(15)
)
我想对它进行求和操作,就像这样
Select SUM(Price) from tblCartItem where CartId='107'
我正在尝试以下代码,但它没有起作用
ObjTempCart.CartTotal = (from c in db.tblCartItems where c.CartId == cartId select c.Price).Sum();
有人可以帮我使用Entity Framework完成这个任务吗? 我正在使用MVC 4 Razor。
Price
是字符串(nvarchar(15)
)? - Ivan Stoev