Tridip Bhattacharjee

Tridip Bhattacharjee

  • NA
  • 1.2k
  • 77.7k

How to fetch master detail data using EF and LINQ

Jan 4 2018 6:28 AM


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)