Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have one of two possible scenarios:</p> <ol> <li><p><code>Item</code> has a relationship to <code>Account</code> (expressed in your Entity Model as a EntityAssociation and in DB as a foreign key):</p></li> <li><p>There is no relationship between <code>Item</code> set and <code>Account</code> set, hence, you must specify a join in LINQ as you have done.</p></li> </ol> <p>Case 1: if this is the case, then you don't need a join statement... by selecting <code>Acount.Item</code> will naturally give you all items where <code>Item.AccountID</code> is equal to <code>Account.ID</code></p> <p><em>So your join statement: <code>join m in _entities.Item on acct.Id equals m.Account.Id</code> has basically told <code>Item</code> to loop back onto <code>Account</code> to check the ID. If they were not already connected, then you could not have gotten <code>m.Account.ID</code></em></p> <p>Case 2: If there is no relationship between <code>Account</code> and <code>Item</code>, then the <code>.Include()</code> will definitely not work because the navigational property DOES NOT exist in your model.</p> <p>Conclusion: Check your new model to see if a relationship exists between <code>Account</code> and <code>Item</code>. If yes, then remove the Join. If no relationship, then you've done something wrong.</p> <p>Here is a select statement assuming scenario 1 and that <code>Account.Item</code> is not a collection:</p> <pre><code>var account = from acct in _entities.Account.Include("Item.ItemDetails") where acct.Id == accountId &amp;&amp; acct.Item.ItemNumber.EndsWith(itemNumber) select acct; </code></pre>
    singulars
    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. This table or related slice is empty.
    1. 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