I have a datagrid, named order开发者_C百科ItemsGrid, which contains the columns (or TextColumn Headers, to prevent confusion) Item Name, Unit Price, Quantity, and Amount (Amount=Quantity*unitPrice) of each item that a customer has ordered in an order. I would like to fetch the info to this grid from a SQL Express 2008 R2 Database, called Business, using LINQ to SQL. But the problem is, the columns ItemName and Price exist in the table named ITEMS and the columns Quantity and Amount are in ORDER_ITEMS.
Relationships:
FK_ORDER_ITEMS_ORDERS (OrderID) FK_ORDER_ITEMS_ITEMS (ItemID)The database diagram is here:
Please revert with comments.
You can use joins in LINQ, that is not problem, in linq query you can create new type with columns what you just need, hat will be properties in that new type, you can give them other names . That list, result of query, can be DataSource for your grid. If you need help with joins or query tell
精彩评论