Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am using asp.net mvc 5,entity frmework 5, linq

i have following tables:
order:
1. orderid customerid
       1          2
       2          3
       3          1

orderDetail:
orderid   productname   quantity
   1         A              10
   1        B              15
   1        C              20

I want to find the quantity/customer

i.e i want to make a report like:

Total Quantity per customer:

            total       total     total
             Qty        Qty       Qty
productname   customer1   customer2 customer3  
1               2            3         33
2               3            2         24
3               4           22         34

what is the query for this?
and
how i can implement random column in a report?

C#
var query=from p in db.orders
group p.customer by p.orders
into g
select new 
{orders=g.order.tolist()}

but this query is only giving me
orders and customers
Posted
Updated 20-Nov-14 8:31am
v3
Comments
Tomas Takac 20-Nov-14 13:19pm    
What did you try so far? Can you post some code?
Member 9129971 20-Nov-14 13:36pm    
actually i dont know how to do this so how can i try if i have no idea what to do?
i am editing me questions to add what i have tried so have a look at it, the random colmn in a report can be implemented by a pivot table but i dont know how to implement it in linq, kindly inform me if anymore details are required in my question

1 solution

 
Share this answer
 
v3
Comments
Member 9129971 20-Nov-14 13:39pm    
thanks but both the links contain only the query for a single table but in my scenrio there are two tables,
and also in there is no clue about dynamic columns in a report
/\jmot 20-Nov-14 14:01pm    
ok, let me see.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900