Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
xamgrids to support Master-details with customer, order, order details entities
posted
Greetings friends,
I have a question...

How would the code behind look (programatically speaking) to support master-details binding?. I saw a demo with thre lines of code in the loaded even to support a grid t :-)) My question is assuming if you had three xamgrids

1. Customers,
2. Orders per customer and,
3. Details per order.

Code would look like this...

 

 

 

private void Page_Loaded(object sender, RoutedEventArgs e)

{

 

 

NorthwindContext ctx = new NorthwindContext();

dataGrid1.ItemsSource = ctx.Customers;

ctx.Load(ctx.GetCustomersQuery());

//What additional code would you add two support two additinal xamgrids?

}

 

 

 

 

 

 

 

 



Looking forward to your response,
Best regards,

Parents
No Data
Reply
  • 12631
    posted

    You can use the Include method in your LINQ query:

    var customers = from o in cdx.Customers.Include("Orders"select o;
    

     This tells LINQ to include the Orders in its result, and you can chain multiple Include methods.

    See http://msdn.microsoft.com/en-us/library/bb738708.aspx for more info.

    One word of caution, when using the Include method, its pretty easy to balloon the number of objects included in the query.  If your planning to return the result of the query via web service, you might start running up against the WCF message size limits.

    Devin

Children
No Data