3
Answers

How to fetch master detail data using EF and LINQ



suppose i have a order and order detail entity. i want to fetch specific order data and its related order detail by EF.

can i use this LINQ query

IEnumerable<Order> order= _ctx.order
.Include(x => x.orderdetails)
.Where(x => x.OrderID== _OrderID).ToList();

does the above code works fine? also tell me how to achieve the same with join also?

also tell me if i need to show specific customer data and customer order and order details then how i need to compose my EF query? help me with code. thanks

Answers (3)

0
Photo of alex alex
NA 27 647 8y
I need more details,would you please make some changes on sample which has been sent to you?
0
Photo of Saineshwar Bageri
NA 20.1k 11.2m 8y
 Do in Document.ready function of Jquery.
 
1. Bind main dropdownlist and provide ID of dropdownlist selected from Model.
2. then if first dropdownlist is selected then call your ajax script Document.ready function in to bind  Second dropdownlist and then to set selected values just get value from Model and set it.
 
 Reference :-
http://www.c-sharpcorner.com/UploadFile/4d9083/filter-webgrid-with-cascading-dropdownlist-along-with-paging/