.net - Eager loading child lists in LINQ to SQL -


I am trying to customize SQL request from a LINQ so that it results in a single SQL statement. At the moment I have something like this:

edit : "Where" filter was removed for clarity - this is also the "ID" primary key Database types for types of objects

  Hotel = (DB. Please provide rooms from H = Hotel in the RBB hotel room where r.HotelId == HID select new HotelRoom {ID = R.Id, code = r.Code, category = r.Category}) Select new hotel {id = h. id, name = h.name, room = room.Tolic ()})FirstOver Default ();  

Where Hotel Business Level Class is defined:

  Public Class Hotel {Public Ent ID}; Set; } Public string name {get; Set; } Public listing & lt; HotelRoom & gt; Room {find; Set; }}  

Where query query is executed, dots are using starters to create business objects when flying from data enforcement organizations.

The problem is that .toList () causes the hotel on the collection of rooms. The collection can be spaced through a second question.

Is there a way to populate the property with all the hotels instead of property without generating additional questions?

Rows in the fashion directly from database Var joinRows = (H to DB. Hotel where h Name == Name is from HR H. Choose Hotel Room New {HotelRow = h, HotelRoomRow = hr}.) List (); // Shape the data locally in the list & lt; Hotels & gt; Results = joinRows from row in group line Hotel Row By Line Row G in the Hotel RO H = G Select Kei New Hotel () {ID = H. Id, name = h. Name, Room = (Choose a new hotel room in R. G) (ID = RIID, Code = R. Code, Category = R. Category}). ToList ()};

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -