manhthaodn 0 Light Poster

My project using the Entity Framework (Linq to Entities). In DTO layer, I use POCO Entity.

I used Eager Loading to load data (Include Method) as follows:

 public IList<Order> Get_OrderWithOrderDetails(int orderID)
        {
            using (var db = new NorthwindEntities())
            {                
                db.ContextOptions.LazyLoadingEnabled = false;
                var query = from o in db.Orders.Include("Customer").Include("Order_Details")
                            where o.OrderID == orderID select o;                
                return query.ToList();
            }
        }
  • with the Northwind database

I'm having trouble following:

  • Query results are wrong (Example: Order ID = 10248): The result after performing the method on only the 1 results; If using sql command will check out 3 results found
  • How to choose the data I need without taking all
  • I can not use LINQ query, something like: .Include (c => c.OrderID = ...). only for use string in Include