开发者

C# | WPF | DataGrid - Binding to the sources from two Tables

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:

C# | WPF | DataGrid - Binding to the sources from two Tables

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜