I have a table.
create table tblCartItem( pkCartItemId int primary key identity, CartId int not null, ProductId int not null, Quantity int not null, Price nvarchar(15) )
and I want to perform sum opeartion on that like as
Select SUM(Price) from tblCartItem where CartId='107'
and I am trying to following code but its not working
ObjTempCart.CartTotal = (from c in db.tblCartItems where c.CartId == cartId select c.Price).Sum();
Any one help me to do this using Entity Framework. I am using MVC 4 Razor.
May be You can use lambda Expression
var total=db.tblCartItems.Where(t=>t.CartId == cartId).Sum(i=>i.Price);