Error when executing sql to generate derived model

Posts   
 
    
Posts: 1
Joined: 21-Nov-2025
# Posted on: 21-Nov-2025 15:00:19   

We just started using derived models to generate DTO's, but a complex one fails when executing SQL, with invalid generated sql

This is the generated SQL that fails because the syntax is not correct:

exec sp_executesql N'
SELECT [__L2_0].[ID] AS [Id], 
       1 AS [LLBLV_2], 
       [__L2_0].[Omschrijving],
       [__L2_0].[SortBy], 
       [__L2_0].[StamHoofdStukID] AS [StamHoofdStukId], 
       [LPA__4].[ID] AS [Id1], 
       [LPA__4].[Omschrijving] AS [Omschrijving1], 
       [LPA__4].[SortBy] AS [SortBy1], 
       [LPA__4].[StamHoofdID] AS [StamHoofdId],
       [__L2_0].[Subtotaal], 
       [__L2_0].[HoofdID] AS [HoofdId] 
  FROM ((([dbo].[Variant] [LPA__1] 
  LEFT JOIN [dbo].[Hoofdkosten] [LPA__2] ON [LPA__2].[VariantID] = [LPA__1].[ID]) 
  LEFT JOIN [dbo].[HoofdStukKosten] [LPA__3] ON [LPA__3].[HoofdID] = [LPA__2].[ID]) 
  INNER JOIN dbo].[StamHoofdStukKosten] [LPA__4] ON [LPA__3].[StamHoofdStukID] = [LPA__4].[ID]) 
 WHERE ( ( [__L2_0].[HoofdID] IN (@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11)))',N'@p1 int,@p2 int,@p3 int,@p4 int,@p5 int,@p6 int,@p7 int,@p8 int,@p9 int,@p10 int,@p11 int',@p1=75828,@p2=75829,@p3=75830,@p4=75831,@p5=75832,@p6=75833,@p7=75834,@p8=75835,@p9=75836,@p10=75837,@p11=75838

EDIT: This error occurs when using the 'Adapter, C#, QuerySpec' approach. I did some more testing and found at that using the 'Adapter, C#, Linq' approach, it does work 😅

Attachments
Filename File size Added on Approval
DbDiagram.png 6,161 21-Nov-2025 15:00.49 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39988
Joined: 17-Aug-2003
# Posted on: 22-Nov-2025 09:17:35   

You give no info regarding the entity structure, what query you ran, nor which version you're using.

So I have to guess and from the looks of it it looks like you're using inheritance? Inheritance and DTOs aren't supported or at least, very limited.

Frans Bouma | Lead developer LLBLGen Pro