Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should have <a href="http://msdn.microsoft.com/en-us/library/bb399198.aspx" rel="nofollow noreferrer">associations</a> between <code>Message</code> and <code>Person</code>. Since the EF designer creates them automatically, you probably already do. However, since they will be generated from foreign keys instead of from column names, the automatically-created associations were probably created with less-than-useful names, like <code>Message.Person1</code> or something. You can select them in the designer and rename them to a more useful name. </p> <p>Let's presume your associations are called <code>Message.FromPerson</code> and <code>Message.ToPerson</code>. You'll then be able to write queries like:</p> <pre><code> var messages = from m in _entities.Message select new BizObjects.Message { MessageId = m.MessageId, From = new BizObjects.Person { PersonId = m.FromPerson.PersonId, PersonName = m.FromPerson.PersonName }, To = new BizObjects.Person { PersonId = m.ToPerson.PersonId, PersonName = m.ToPerson.PersonName }, Subject = m.Subject, Content = m.Content, Read = m.Read, CreatedOn = m.CreatedOn, }; </code></pre> <p>By using the association properties in my LINQ to Entities query, I am causing the Entity Framework to transliterate this reference into a <code>LEFT OUTER JOIN</code> in SQL. </p> <p>This is a very efficient way to load the data (especially in contrast to lazy loading, which causes multiple database queries for far too many columns), since you only select the columns you actually need and it is all done in one query.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload