Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The type is different because your <code>newElement.ElementToComponentMappings</code> is collection but your query returns only single instance.</p> <p>You can try to use this:</p> <pre><code>context.ContextOptions.LazyLoadingEnabled = false; var newElement = (from c in context.ModelElements where c.ModelID == modelID &amp;&amp; c.ElementNo == modelElementNo select c).FirstOrDefault(); var mapping = (from m in context.ElementToComponentMappings where m.ModelID == modelID &amp;&amp; m.ElementNo == modelElementNo &amp;&amp; m.version == version select m).FirstOrDefault(); // now check if newElement.ElementToComponentMappings contains your single item </code></pre> <p>You can also try to use this:</p> <pre><code>context.ContextOptions.LazyLoadingEnabled = false; var newElement = (from c in context.ModelElements where c.ModelID == modelID &amp;&amp; c.ElementNo == modelElementNo select c).FirstOrDefault(); ((EntityCollection&lt;ElementToComponentMappings&gt;)newElement.ElementToComponentMappings) .CreateSourceQuery() .FirstOrDefault(m.version == version); // You don't need to check FKs here // now check if newElement.ElementToComponentMappings contains your single item </code></pre> <p>Neither of these methods works if your type is proxied and lazy loading is enabled because this expected automatic relation fixup will not mark navigation property as loaded (if you have lazy loading enabled next access to the property will trigger lazy loading and load all other entities).</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. This table or related slice is empty.
    1. VO
      singulars
      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