In model i have IEntityBase with

[Key]
Guid Id { get; }

All my entities is implements IEntityBase. In Query

Query.All<IEntityBase>().Where(a => a.Id == id)

I got non optimal sql like this:

SELECT  [a].[Id] ,
        [a].[TypeId]
FROM    ( (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((SELECT
                                                              [b].[Id] ,
                                                              [b].[TypeId]
                                                              FROM
                                                              ( SELECT
                                                              [c].[Id] ,
                                                              189 AS [TypeId]
                                                              FROM
                                                              [dbo].[Entity1] [c]
                                                              ) [b])
          UNION
          ( SELECT  [d].[Id] ,
                    [d].[TypeId]
            FROM    ( SELECT    [e].[Id] ,
                                190 AS [TypeId]
                      FROM      [dbo].[Entity2] [e]
                    ) [d]
          ))
          UNION
...
          ( SELECT  [t10].[Id] ,
                    [t10].[TypeId]
            FROM    ( SELECT    [u10].[Id] ,
                                204 AS [TypeId]
                      FROM      [dbo].[EntityN] [u10]
                    ) [t10]
          )
        ) [a]
WHERE   ( [a].[Id] = @p0_0 ) ;

In some domains it not work (SQL error details 'Type: SyntaxError;' Query 'SELECT [a].[Id], [a].[TypeId] FROM Original message 'Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.')

Reproduced on: DataObjects.Net, 4.6.0 Beta 3, Net40-Release, 9eae80f005b3:2012-09-14 DataObjects.Net, 4.5.4, Net40-Release, 52fbc8e33e5d:2012-08-11

asked Sep 17 '12 at 03:05

pil0t's gravatar image

pil0t
207545763


One Answer:

Fixed and will be included in 4.5.5 release

answered Sep 17 '12 at 06:50

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

edited Sep 17 '12 at 06:50

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA