Note that there are some explanatory texts on larger screens.

plurals
  1. POIN Clause from an included table, doesn't works as expected
    text
    copied!<p>I'm trying to do this:</p> <pre><code> var results = (from s in db.ExampleMaster .Include("State") .Include("Group") .Where("it.Group.IdGroup in {1,2,3,4,5}") .Where("it.IdState in {1,2}") select s); </code></pre> <p>The Schema:</p> <pre><code>ExampleMaster: IdExampleMaster int, IdState int State: IdState int, Description varchar(100) Group: IdGroup int IdExampleMaster int </code></pre> <p>The SQL Desired is like:</p> <pre><code>SELECT * FROM ExampleMaster e inner join State s on s.IdState = e.IdState Inner join Group g on e.IdExampleMaster = g.IdExampleMaster where g.IdGroup in (1,2,3,4,5) and e.IdState in (1,2) </code></pre> <p>The SQL Generated is like:</p> <pre><code>SELECT * FROM ExampleMaster AS [Extent1] LEFT OUTER JOIN [dbo].[Group] AS [Extent2] ON [Extent1].[IdExampleMaster] = [Extent2].[IdGroup] LEFT OUTER JOIN [dbo].[Group] AS [Extent3] ON [Extent2].[IdGroup] = [Extent3].[IdGroup] LEFT OUTER JOIN [dbo].[Group] AS [Extent4] ON [Extent2].[IdGroup] = [Extent4].[IdGroup] LEFT OUTER JOIN [dbo].[Group] AS [Extent5] ON [Extent2].[IdGroup] = [Extent5].[IdGroup] LEFT OUTER JOIN [dbo].[Group] AS [Extent6] ON [Extent2].[IdGroup] = [Extent6].[IdGroup] LEFT OUTER JOIN [dbo].[Group] AS [Extent7] ON [Extent2].[IdGroup] = [Extent7].[IdGroup] LEFT OUTER JOIN [dbo].[State] AS [Extent8] ON [Extent1].[IdState] = [Extent8].[IdState] WHERE ([Extent1].[IdState] IN (1,2)) AND ([Extent3].[IdGroup] = 1 OR [Extent4].[IdGroup] = 2 OR [Extent5].[IdGroup] = 3 OR [Extent6].[IdGroup] = 4 OR [Extent7].[IdGroup] = 5) ) AS [Filter1] </code></pre> <p>I don't understand why the state case (no Included table required) works well with IN clause and the Group make so many joins than items on the list and even that it doesn't works as expected.</p> <p>Any idea?</p> <hr> <h2><strong>EDITED</strong></h2> <p>I found an error on my database schema, now the error I get with</p> <pre><code>.Where("it.Group.IdGroup in {1,2,3,4,5}") </code></pre> <p>Is </p> <blockquote> <p>'IdGroup' is not a member of 'Transient.collection[myModel.Group(Nullable=True,DefaultValue=)]'. To extract a property of a collection element, use a subquery to iterate over the collection</p> </blockquote>
 

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