title: Linq not loading related entities consistently
body: <p>I'm using DotConnecto for SQLite. </p>
  
  <p>I have contacted DevArt support but have not got an reply yet, and need to sort this out as soon as possible.</p>
  
  <p>I'm loading these related entities like this:</p>
  
  <pre><code> Dim Dimensions = From c In context.Dimensions.Include("Cubes").Include("DimensionTIs").Include("DimensionSubsets").Include("DimensionAttributes").Include("DimensionElements") Where c.dbModelID_FK = 1
                                           Select c
  </code></pre>
  
  <p>I am not getting the "order" related entities to customer number 2. I'm getting all the orders.</p>
  
  <p>The context gets stored properly, and the all the data is consistent but somehow when I am loading it I get inconsistencies loading related entities.</p>
  
  <p>I am getting 8 when I should be getting the 3 related orders to customer 2. </p>
  
  <p>Can anyone point me out on where to start looking at? 
  Or an alternative solution?</p>
  
  <p>Thanks!</p>
  
  <p>UPDATE</p>
  
  <p>Source query</p>
  
  <pre><code>SELECT   
  UnionAll4.C2 AS C1,  UnionAll4.C3 AS C2,  UnionAll4.C4 AS C3,  UnionAll4.C5 AS C4,  UnionAll4.C6 AS C5, 
  UnionAll4.C7 AS C6,  UnionAll4.C8 AS C7,  UnionAll4.C9 AS C8,  UnionAll4.C10 AS C9,  UnionAll4.C11 AS C10,  
  UnionAll4.C12 AS C11,  UnionAll4.C1 AS C12,  UnionAll4.C13,  UnionAll4.C14,  UnionAll4.C15,  UnionAll4.C16,  
  UnionAll4.C17,  UnionAll4.C18,  UnionAll4.C19,  UnionAll4.C20,  UnionAll4.C21,  UnionAll4.C22,  UnionAll4.C23,  
  UnionAll4.C24,  UnionAll4.C25,  UnionAll4.C26,  UnionAll4.C27,  UnionAll4.C28,  UnionAll4.C29,  UnionAll4.C30,  
  UnionAll4.C31,  UnionAll4.C32,  UnionAll4.C33,  UnionAll4.C34,  UnionAll4.C35,  UnionAll4.C36,  UnionAll4.C37,  
  UnionAll4.C38,  UnionAll4.C39,  UnionAll4.C40,  UnionAll4.C41,  UnionAll4.C42,  UnionAll4.C43,  UnionAll4.C44,  
  UnionAll4.C45,  UnionAll4.C46,  UnionAll4.C47,  UnionAll4.C48,  UnionAll4.C49,  UnionAll4.C50,  UnionAll4.C51,  
  UnionAll4.C52,  UnionAll4.C53,  UnionAll4.C54,  UnionAll4.C55,  UnionAll4.C56,  UnionAll4.C57,  UnionAll4.C58,  
  UnionAll4.C59,  UnionAll4.C60,  UnionAll4.C61,  UnionAll4.C62,  UnionAll4.C63,  UnionAll4.C64,  UnionAll4.C65,  
  UnionAll4.C66,  UnionAll4.C67,  UnionAll4.C68,  UnionAll4.C69,  UnionAll4.C70,  UnionAll4.C71,  UnionAll4.C72,  
  UnionAll4.C73,  UnionAll4.C74,  UnionAll4.C75,  UnionAll4.C76  
  FROM  (SELECT    UnionAll3.C1,   UnionAll3.C2,   
  UnionAll3.C3,   UnionAll3.C4,   UnionAll3.C5,   UnionAll3.C6,   UnionAll3.C7,   UnionAll3.C8,   UnionAll3.C9,   
  UnionAll3.C10,   UnionAll3.C11,   UnionAll3.C12,   UnionAll3.C13,   UnionAll3.C14,   UnionAll3.C15,   UnionAll3.C16,   
  UnionAll3.C17,   UnionAll3.C18,   UnionAll3.C19,   UnionAll3.C20,   UnionAll3.C21,   UnionAll3.C22,   UnionAll3.C23,   
  UnionAll3.C24,   UnionAll3.C25,   UnionAll3.C26,   UnionAll3.C27,   UnionAll3.C28,   UnionAll3.C29,   UnionAll3.C30,   
  UnionAll3.C31,   UnionAll3.C32,   UnionAll3.C33,   UnionAll3.C34,   UnionAll3.C35,   UnionAll3.C36,   UnionAll3.C37,   
  UnionAll3.C38,   UnionAll3.C39,   UnionAll3.C40,   UnionAll3.C41,   UnionAll3.C42,   UnionAll3.C43,   UnionAll3.C44,   
  UnionAll3.C45,   UnionAll3.C46,   UnionAll3.C47,   UnionAll3.C48,   UnionAll3.C49,   UnionAll3.C50,   UnionAll3.C51,   
  UnionAll3.C52,   UnionAll3.C53,   UnionAll3.C54,   UnionAll3.C55,   UnionAll3.C56,   UnionAll3.C57,   UnionAll3.C58,   
  UnionAll3.C59,   UnionAll3.C60,   UnionAll3.C61,   UnionAll3.C62,   UnionAll3.C63,   UnionAll3.C64,   UnionAll3.C65,   
  UnionAll3.C66,   UnionAll3.C67,   UnionAll3.C68,   UnionAll3.C69,   UnionAll3.C70,   UnionAll3.C71,   UnionAll3.C72,   
  UnionAll3.C73,   UnionAll3.C74,   UnionAll3.C75,   UnionAll3.C76   
  FROM  (SELECT     UnionAll2.C1,    UnionAll2.C2,    
  UnionAll2.C3,    UnionAll2.C4,    UnionAll2.C5,    UnionAll2.C6,    UnionAll2.C7,    UnionAll2.C8,    UnionAll2.C9,    
  UnionAll2.C10,    UnionAll2.C11,    UnionAll2.C12,    UnionAll2.C13,    UnionAll2.C14,    UnionAll2.C15,    
  UnionAll2.C16,    UnionAll2.C17,    UnionAll2.C18,    UnionAll2.C19,    UnionAll2.C20,    UnionAll2.C21,    
  UnionAll2.C22,    UnionAll2.C23,    UnionAll2.C24,    UnionAll2.C25,    UnionAll2.C26,    UnionAll2.C27,    
  UnionAll2.C28,    UnionAll2.C29,    UnionAll2.C30,    UnionAll2.C31,    UnionAll2.C32,    UnionAll2.C33,    
  UnionAll2.C34,    UnionAll2.C35,    UnionAll2.C36,    UnionAll2.C37,    UnionAll2.C38,    UnionAll2.C39,    
  UnionAll2.C40,    UnionAll2.C41,    UnionAll2.C42,    UnionAll2.C43,    UnionAll2.C44,    UnionAll2.C45,    
  UnionAll2.C46,    UnionAll2.C47,    UnionAll2.C48,    UnionAll2.C49,    UnionAll2.C50,    UnionAll2.C51,    
  UnionAll2.C52,    UnionAll2.C53,    UnionAll2.C54,    UnionAll2.C55,    UnionAll2.C56,    UnionAll2.C57,    
  UnionAll2.C58,    UnionAll2.C59,    UnionAll2.C60,    UnionAll2.C61,    UnionAll2.C62,    UnionAll2.C63,    
  UnionAll2.C64,    UnionAll2.C65,    UnionAll2.C66,    UnionAll2.C67,    UnionAll2.C68,    UnionAll2.C69,    
  UnionAll2.C70,    UnionAll2.C71,    UnionAll2.C72,    UnionAll2.C73,    UnionAll2.C74,    UnionAll2.C75,    
  UnionAll2.C76    
  FROM  (SELECT      UnionAll1.C1,     UnionAll1.dbDimensionID AS C2,     UnionAll1.dbDimensionID1 AS C3,     
  UnionAll1.dbModelID_FK AS C4,     UnionAll1.DimensionName AS C5,     UnionAll1.Description AS C6,     
  UnionAll1.ChangeDate AS C7,     UnionAll1.GenerateDate AS C8,     UnionAll1.ID AS C9,     
  UnionAll1.GID AS C10,     UnionAll1.dbAttribute_dbAttributeID AS C11,     UnionAll1.dbElement_dbElementID AS C12,     
  UnionAll1.dbCubeID AS C13,     UnionAll1.dbModelID_FK1 AS C14,     UnionAll1.Description1 AS C15,     
  UnionAll1.GID1 AS C16,     UnionAll1.CubeName AS C17,     UnionAll1.GenerateDate1 AS C18,     UnionAll1.ID1 AS C19,     
  UnionAll1.Definition AS C20,     UnionAll1.CubeDate AS C21,     UnionAll1.ImageMap AS C22,     
  UnionAll1.ImageMapRuleFlows AS C23,     UnionAll1.ImageMapProcessAndDS AS C24,     UnionAll1.ImageMapSummary AS C25,     
  UnionAll1.C2 AS C26,     UnionAll1.C3 AS C27,     UnionAll1.C4 AS C28,     UnionAll1.C5 AS C29,     UnionAll1.C6 AS C30,     
  UnionAll1.C7 AS C31,     UnionAll1.C8 AS C32,     UnionAll1.C9 AS C33,     UnionAll1.C10 AS C34,     UnionAll1.C11 AS C35,     
  UnionAll1.C12 AS C36,     UnionAll1.C13 AS C37,     UnionAll1.C14 AS C38,     UnionAll1.C15 AS C39,     UnionAll1.C16 AS C40,     
  UnionAll1.C17 AS C41,     UnionAll1.C18 AS C42,     UnionAll1.C19 AS C43,     UnionAll1.C20 AS C44,     UnionAll1.C21 AS C45,     
  UnionAll1.C22 AS C46,     UnionAll1.C23 AS C47,     UnionAll1.C24 AS C48,     UnionAll1.C25 AS C49,     UnionAll1.C26 AS C50,     
  UnionAll1.C27 AS C51,     UnionAll1.C28 AS C52,     UnionAll1.C29 AS C53,     UnionAll1.C30 AS C54,     UnionAll1.C31 AS C55,     
  UnionAll1.C32 AS C56,     UnionAll1.C33 AS C57,     UnionAll1.C34 AS C58,     UnionAll1.C35 AS C59,     UnionAll1.C36 AS C60,     
  UnionAll1.C37 AS C61,     UnionAll1.C38 AS C62,     UnionAll1.C39 AS C63,     UnionAll1.C40 AS C64,     UnionAll1.C41 AS C65,     
  UnionAll1.C42 AS C66,     UnionAll1.C43 AS C67,     UnionAll1.C44 AS C68,     UnionAll1.C45 AS C69,     UnionAll1.C46 AS C70,     
  UnionAll1.C47 AS C71,     UnionAll1.C48 AS C72,     UnionAll1.C49 AS C73,     UnionAll1.C50 AS C74,     UnionAll1.C51 AS C75,     
  UnionAll1.C52 AS C76     FROM  (SELECT       CASE WHEN Join1.dbDimensionID IS NULL THEN  CAST(NULL AS int32) ELSE 1 END AS C1,      
  Extent1.dbDimensionID,      Extent1.dbDimensionID AS dbDimensionID1,      Extent1.dbModelID_FK,      Extent1.DimensionName,      
  Extent1.Description,      Extent1.ChangeDate,      Extent1.GenerateDate,      Extent1.ID,      Extent1.GID,      
  Extent1.dbAttribute_dbAttributeID,      Extent1.dbElement_dbElementID,      Join1.dbCubeID1 AS dbCubeID,      
  Join1.dbModelID_FK AS dbModelID_FK1,      Join1.Description AS Description1,      Join1.GID AS GID1,      
  Join1.CubeName,      Join1.GenerateDate AS GenerateDate1,      Join1.ID AS ID1,      Join1.Definition,      
  Join1.CubeDate,      Join1.ImageMap,      Join1.ImageMapRuleFlows,      Join1.ImageMapProcessAndDS,      
  Join1.ImageMapSummary,       
  CAST(NULL AS int32) AS C2,       CAST(NULL AS int32) AS C3,       CAST(NULL AS text) AS C4,       
  CAST(NULL AS text) AS C5,       CAST(NULL AS text) AS C6,       CAST(NULL AS text) AS C7,       
  CAST(NULL AS text) AS C8,       CAST(NULL AS text) AS C9,       CAST(NULL AS text) AS C10,       
  CAST(NULL AS text) AS C11,       CAST(NULL AS text) AS C12,       CAST(NULL AS text) AS C13,       
  CAST(NULL AS text) AS C14,       CAST(NULL AS text) AS C15,       CAST(NULL AS text) AS C16,      
   CAST(NULL AS text) AS C17,       CAST(NULL AS text) AS C18,       CAST(NULL AS text) AS C19,       
   CAST(NULL AS text) AS C20,       CAST(NULL AS text) AS C21,       CAST(NULL AS text) AS C22,       
   CAST(NULL AS text) AS C23,       CAST(NULL AS text) AS C24,       CAST(NULL AS int32) AS C25,      
    CAST(NULL AS int32) AS C26,       CAST(NULL AS text) AS C27,       CAST(NULL AS text) AS C28,       
    CAST(NULL AS text) AS C29,       CAST(NULL AS text) AS C30,       CAST(NULL AS text) AS C31,       
    CAST(NULL AS text) AS C32,       CAST(NULL AS text) AS C33,       CAST(NULL AS text) AS C34,       
    CAST(NULL AS text) AS C35,       CAST(NULL AS int32) AS C36,       CAST(NULL AS int32) AS C37,       
    CAST(NULL AS int32) AS C38,       CAST(NULL AS text) AS C39,       CAST(NULL AS text) AS C40,       
    CAST(NULL AS text) AS C41,       CAST(NULL AS text) AS C42,       CAST(NULL AS text) AS C43,       
    CAST(NULL AS text) AS C44,       CAST(NULL AS int32) AS C45,       CAST(NULL AS int32) AS C46,       
    CAST(NULL AS int32) AS C47,       CAST(NULL AS text) AS C48,       CAST(NULL AS text) AS C49,       
    CAST(NULL AS text) AS C50,       CAST(NULL AS text) AS C51,       CAST(NULL AS text) AS C52      
    FROM  Dimension AS Extent1      LEFT OUTER JOIN  (SELECT        Extent2.dbDimensionID,       
    Extent2.dbCubeID AS dbCubeID2,       Extent3.dbCubeID AS dbCubeID1,       Extent3.dbModelID_FK,       
    Extent3.Description,       Extent3.GID,       Extent3.CubeName,       Extent3.GenerateDate,       
    Extent3.ID,       Extent3.Definition,       Extent3.CubeDate,       Extent3.ImageMap,       
    Extent3.ImageMapRuleFlows,       Extent3.ImageMapProcessAndDS,       Extent3.ImageMapSummary       
    FROM  "Dimension-Cube" AS Extent2       
  INNER JOIN Cube AS Extent3 ON Extent3.dbCubeID = Extent2.dbCubeID ) AS Join1 ON Extent1.dbDimensionID = Join1.dbDimensionID      
  WHERE Extent1.dbModelID_FK = :p__linq__0     
  UNION ALL      
  SELECT       2 AS C1,      Extent4.dbDimensionID,      Extent4.dbDimensionID AS dbDimensionID1,      
  Extent4.dbModelID_FK,      Extent4.DimensionName,      Extent4.Description,      Extent4.ChangeDate,      
  Extent4.GenerateDate,      Extent4.ID,      Extent4.GID,      Extent4.dbAttribute_dbAttributeID,      
  Extent4.dbElement_dbElementID,       CAST(NULL AS int32) AS C2,       CAST(NULL AS int32) AS C3,      
   CAST(NULL AS text) AS C4,       CAST(NULL AS text) AS C5,       CAST(NULL AS text) AS C6,      
    CAST(NULL AS text) AS C7,       CAST(NULL AS text) AS C8,       CAST(NULL AS text) AS C9,      
     CAST(NULL AS text) AS C10,       CAST(NULL AS text) AS C11,       CAST(NULL AS text) AS C12,       
     CAST(NULL AS text) AS C13,       CAST(NULL AS text) AS C14,      Join3.dbTiID1 AS dbTiID,      
     Join3.dbModelID_FK AS dbModelID_FK1,      Join3.TiName,      Join3.Description AS Description1,      
     Join3.GenerateDate AS GenerateDate1,      Join3.ID AS ID1,      Join3.EditDate,      
     Join3.DataSource,      Join3.Prolog,      Join3.Meta,      Join3.Data,      Join3.Epilog,      
     Join3.PrologCode,      Join3.DataCode,      Join3.MetaDataCode,      Join3.SourceType,      
     Join3.SourceLocation,      Join3.FilePath,      Join3.SourceContent,      Join3.EpilogCode,      
     Join3.Author,      Join3.Change,      Join3.General,       CAST(NULL AS int32) AS C15,      
      CAST(NULL AS int32) AS C16,       CAST(NULL AS text) AS C17,       CAST(NULL AS text) AS C18,       
      CAST(NULL AS text) AS C19,       CAST(NULL AS text) AS C20,       CAST(NULL AS text) AS C21,      
       CAST(NULL AS text) AS C22,       CAST(NULL AS text) AS C23,       CAST(NULL AS text) AS C24,      
        CAST(NULL AS text) AS C25,       CAST(NULL AS int32) AS C26,       CAST(NULL AS int32) AS C27,       
        CAST(NULL AS int32) AS C28,       CAST(NULL AS text) AS C29,       CAST(NULL AS text) AS C30,       
        CAST(NULL AS text) AS C31,       CAST(NULL AS text) AS C32,       CAST(NULL AS text) AS C33,       
        CAST(NULL AS text) AS C34,       CAST(NULL AS int32) AS C35,       CAST(NULL AS int32) AS C36,       
        CAST(NULL AS int32) AS C37,       CAST(NULL AS text) AS C38,       CAST(NULL AS text) AS C39,       
        CAST(NULL AS text) AS C40,       CAST(NULL AS text) AS C41,       CAST(NULL AS text) AS C42      
        FROM  Dimension AS Extent4      INNER JOIN  (SELECT        Extent5.dbTiID AS dbTiID2,       
        Extent5.dbDimensionID,       Extent6.dbTiID AS dbTiID1,       Extent6.dbModelID_FK,       
        Extent6.TiName,       Extent6.Description,       Extent6.GenerateDate,       Extent6.ID,       
        Extent6.EditDate,       Extent6.DataSource,       Extent6.Prolog,       Extent6.Meta,       
        Extent6.Data,       Extent6.Epilog,       Extent6.PrologCode,       Extent6.DataCode,       
        Extent6.MetaDataCode,       Extent6.SourceType,       Extent6.SourceLocation,       Extent6.FilePath,       
        Extent6.SourceContent,       Extent6.EpilogCode,       Extent6.Author,       Extent6.Change,       
        Extent6.General       
        FROM  "Dimension-TI" AS Extent5       
        INNER JOIN TI AS Extent6 ON Extent6.dbTiID = Extent5.dbTiID ) AS Join3 ON Extent4.dbDimensionID = Join3.dbDimensionID      
        WHERE Extent4.dbModelID_FK = :p__linq__0) AS UnionAll1    
        UNION ALL     
        SELECT      3 AS C1,     Extent7.dbDimensionID,     
        Extent7.dbDimensionID AS dbDimensionID1,     Extent7.dbModelID_FK,     Extent7.DimensionName,     Extent7.Description,     
        Extent7.ChangeDate,     Extent7.GenerateDate,     Extent7.ID,     Extent7.GID,     Extent7.dbAttribute_dbAttributeID,     
        Extent7.dbElement_dbElementID,      CAST(NULL AS int32) AS C2,      CAST(NULL AS int32) AS C3,      CAST(NULL AS text) AS C4,      
        CAST(NULL AS text) AS C5,      CAST(NULL AS text) AS C6,      CAST(NULL AS text) AS C7,      CAST(NULL AS text) AS C8,      
        CAST(NULL AS text) AS C9,      CAST(NULL AS text) AS C10,      CAST(NULL AS text) AS C11,      CAST(NULL AS text) AS C12,     
        CAST(NULL AS text) AS C13,      CAST(NULL AS text) AS C14,      CAST(NULL AS int32) AS C15,      CAST(NULL AS int32) AS C16,   
        CAST(NULL AS text) AS C17,      CAST(NULL AS text) AS C18,      CAST(NULL AS text) AS C19,      CAST(NULL AS text) AS C20,    
       CAST(NULL AS text) AS C21,      CAST(NULL AS text) AS C22,      CAST(NULL AS text) AS C23,      CAST(NULL AS text) AS C24,     
       CAST(NULL AS text) AS C25,      CAST(NULL AS text) AS C26,      CAST(NULL AS text) AS C27,      CAST(NULL AS text) AS C28,     
          CAST(NULL AS text) AS C29,      CAST(NULL AS text) AS C30,      CAST(NULL AS text) AS C31,      CAST(NULL AS text) AS C32,      
          CAST(NULL AS text) AS C33,      CAST(NULL AS text) AS C34,      CAST(NULL AS text) AS C35,      CAST(NULL AS text) AS C36,     
           CAST(NULL AS text) AS C37,     Extent8.dbDimSubesetID,     Extent8.dbDimensionID_FK,     Extent8.ID AS ID1,     
           Extent8.DimensionName AS DimensionName1,     Extent8.GenerateDate AS GenerateDate1,     Extent8.SubsetName,     
           Extent8.SubsetType,     Extent8.SubsetDate,     Extent8.SubsetAlias,     Extent8.SubsetExpression,     
           Extent8.NumberOfElements,      CAST(NULL AS int32) AS C38,      CAST(NULL AS int32) AS C39,      
           CAST(NULL AS int32) AS C40,      CAST(NULL AS text) AS C41,      CAST(NULL AS text) AS C42,      CAST(NULL AS text) AS C43,      
           CAST(NULL AS text) AS C44,      CAST(NULL AS text) AS C45,      CAST(NULL AS text) AS C46,      CAST(NULL AS int32) AS C47,      
           CAST(NULL AS int32) AS C48,      CAST(NULL AS int32) AS C49,      CAST(NULL AS text) AS C50,      CAST(NULL AS text) AS C51,      
           CAST(NULL AS text) AS C52,      CAST(NULL AS text) AS C53,      CAST(NULL AS text) AS C54     FROM  Dimension AS Extent7     
           INNER JOIN "DimensionSubset-Dim" AS Extent8 ON Extent7.dbDimensionID = Extent8.dbDimensionID_FK     
           WHERE Extent7.dbModelID_FK = :p__linq__0) AS UnionAll2   
           UNION ALL    
           SELECT     4 AS C1,    Extent9.dbDimensionID,    Extent9.dbDimensionID AS dbDimensionID1,    Extent9.dbModelID_FK,    
           Extent9.DimensionName,    Extent9.Description,    Extent9.ChangeDate,    Extent9.GenerateDate,    Extent9.ID,    E
           xtent9.GID,    Extent9.dbAttribute_dbAttributeID,    Extent9.dbElement_dbElementID,     CAST(NULL AS int32) AS C2,     
           CAST(NULL AS int32) AS C3,     CAST(NULL AS text) AS C4,     CAST(NULL AS text) AS C5,     CAST(NULL AS text) AS C6,     
           CAST(NULL AS text) AS C7,     CAST(NULL AS text) AS C8,     CAST(NULL AS text) AS C9,     CAST(NULL AS text) AS C10,     
           CAST(NULL AS text) AS C11,     CAST(NULL AS text) AS C12,     CAST(NULL AS text) AS C13,     CAST(NULL AS text) AS C14,     
           CAST(NULL AS int32) AS C15,     CAST(NULL AS int32) AS C16,     CAST(NULL AS text) AS C17,     CAST(NULL AS text) AS C18,    
            CAST(NULL AS text) AS C19,     CAST(NULL AS text) AS C20,     CAST(NULL AS text) AS C21,     CAST(NULL AS text) AS C22,    
             CAST(NULL AS text) AS C23,     CAST(NULL AS text) AS C24,     CAST(NULL AS text) AS C25,     CAST(NULL AS text) AS C26,     
             CAST(NULL AS text) AS C27,     CAST(NULL AS text) AS C28,     CAST(NULL AS text) AS C29,     CAST(NULL AS text) AS C30,    
              CAST(NULL AS text) AS C31,     CAST(NULL AS text) AS C32,     CAST(NULL AS text) AS C33,     CAST(NULL AS text) AS C34,    
               CAST(NULL AS text) AS C35,     CAST(NULL AS text) AS C36,     CAST(NULL AS text) AS C37,     CAST(NULL AS int32) AS C38, 
                   CAST(NULL AS int32) AS C39,     CAST(NULL AS text) AS C40,     CAST(NULL AS text) AS C41,     CAST(NULL AS text) AS C42,  
                      CAST(NULL AS text) AS C43,     CAST(NULL AS text) AS C44,     CAST(NULL AS text) AS C45,     CAST(NULL AS text) AS C46,  
                         CAST(NULL AS text) AS C47,     CAST(NULL AS text) AS C48,    Extent10.dbAttributeID,    Extent10.dbDimensionID_FK,    
                         Extent10.dbModelID_FK AS dbModelID_FK1,    Extent10.dimRef,    Extent10.Type,    Extent10.Description AS Description1,  
                           Extent10.Name,    Extent10.GenerateDate AS GenerateDate1,    Extent10.ID AS ID1,     CAST(NULL AS int32) AS C49,   
                             CAST(NULL AS int32) AS C50,     CAST(NULL AS int32) AS C51,     CAST(NULL AS text) AS C52,    
                              CAST(NULL AS text) AS C53,     CAST(NULL AS text) AS C54,     CAST(NULL AS text) AS C55,     
                              CAST(NULL AS text) AS C56    FROM  Dimension AS Extent9    
                              INNER JOIN Attribute AS Extent10 ON Extent9.dbDimensionID = Extent10.dbDimensionID_FK    
                              WHERE Extent9.dbModelID_FK = :p__linq__0) AS UnionAll3  
                              UNION ALL   
                              SELECT    5 AS C1,   Extent11.dbDimensionID,   Extent11.dbDimensionID AS dbDimensionID1,   Extent11.dbModelID_FK,  
                               Extent11.DimensionName,   Extent11.Description,   Extent11.ChangeDate,   Extent11.GenerateDate,   Extent11.ID, 
                                 Extent11.GID,   Extent11.dbAttribute_dbAttributeID,   Extent11.dbElement_dbElementID,   
                                  CAST(NULL AS int32) AS C2,    CAST(NULL AS int32) AS C3,    CAST(NULL AS text) AS C4,    
                                  CAST(NULL AS text) AS C5,    CAST(NULL AS text) AS C6,    CAST(NULL AS text) AS C7,   
                                   CAST(NULL AS text) AS C8,    CAST(NULL AS text) AS C9,    CAST(NULL AS text) AS C10,    
                                   CAST(NULL AS text) AS C11,    CAST(NULL AS text) AS C12,    CAST(NULL AS text) AS C13,   
                                    CAST(NULL AS text) AS C14,    CAST(NULL AS int32) AS C15,    CAST(NULL AS int32) AS C16,  
                                      CAST(NULL AS text) AS C17,    CAST(NULL AS text) AS C18,    CAST(NULL AS text) AS C19,    
                                      CAST(NULL AS text) AS C20,    CAST(NULL AS text) AS C21,    CAST(NULL AS text) AS C22,   
                                       CAST(NULL AS text) AS C23,    CAST(NULL AS text) AS C24,    CAST(NULL AS text) AS C25,   
                                        CAST(NULL AS text) AS C26,    CAST(NULL AS text) AS C27,    CAST(NULL AS text) AS C28,  
                                          CAST(NULL AS text) AS C29,    CAST(NULL AS text) AS C30,    CAST(NULL AS text) AS C31,  
                                            CAST(NULL AS text) AS C32,    CAST(NULL AS text) AS C33,    CAST(NULL AS text) AS C34,   
                                             CAST(NULL AS text) AS C35,    CAST(NULL AS text) AS C36,    CAST(NULL AS text) AS C37,   
                                              CAST(NULL AS int32) AS C38,    CAST(NULL AS int32) AS C39,    CAST(NULL AS text) AS C40,  
                                                CAST(NULL AS text) AS C41,    CAST(NULL AS text) AS C42,    CAST(NULL AS text) AS C43,  
                                                  CAST(NULL AS text) AS C44,    CAST(NULL AS text) AS C45,    CAST(NULL AS text) AS C46,  
                                                    CAST(NULL AS text) AS C47,    CAST(NULL AS text) AS C48,    CAST(NULL AS int32) AS C49,   
                                                     CAST(NULL AS int32) AS C50,    CAST(NULL AS int32) AS C51,    CAST(NULL AS text) AS C52,  
                                                       CAST(NULL AS text) AS C53,    CAST(NULL AS text) AS C54,    CAST(NULL AS text) AS C55,  
                                                         CAST(NULL AS text) AS C56,    CAST(NULL AS text) AS C57,   Extent12.dbElementID,  
                                                          Extent12.dbDimensionID_FK,   Extent12.dbModelID_FK AS dbModelID_FK1,  
                                                           Extent12.GenerateDate AS GenerateDate1,   Extent12.ID AS ID1,   
                                                           Extent12.Name,   Extent12.Description AS Description1,   Extent12.Type   
                                                           FROM  Dimension AS Extent11   
         INNER JOIN Element AS Extent12 ON Extent11.dbDimensionID = Extent12.dbDimensionID_FK   
  
  WHERE Extent11.dbModelID_FK = :p__linq__0) AS UnionAll4  ORDER BY UnionAll4.C3 ASC, UnionAll4.C1 ASC
  </code></pre>