Mike Eghtebas
asked on
Aggregate, LINQ, c#
The following code finds a list of Quantity values ok.
Question: At line 2, how aggregate could be applied to this code to get total quantity?
Question: At line 2, how aggregate could be applied to this code to get total quantity?
Dim s List(Of Order)= (From o In db.Orders Where o.ID = 2).ToList()
Dim sum = From o In s.OrderItems Select Total = o.Quantity
ASKER
Hi Saige,
Orders is in Entity Framework define by db and has data in it.
Dim db As New TestDatabaseEntities
I want to pull that data. If I were doing it in SQL:
Select Sum(o.Quantity) From tblOrders o Where o.ID =2
or
Select o,ID, Sum(o.Quantity) From tblOrders Group By o.ID Having ID =2
Orders is in Entity Framework define by db and has data in it.
Dim db As New TestDatabaseEntities
I want to pull that data. If I were doing it in SQL:
Select Sum(o.Quantity) From tblOrders o Where o.ID =2
or
Select o,ID, Sum(o.Quantity) From tblOrders Group By o.ID Having ID =2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Produces the following output:
-saige-