This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
In my model 2 tables that derive from the same base both have a field called CirtsId. The actual error message : Unable to materialize field [CirtsId] on type [Lwb.Cirts.Server.Services.DataModel.Client]: field is type 'System.Int32' but database returned type 'System.DBNull'. Is being caused because the DBNull is in the column of the same name from the other (wrong) table. Lightspeed is not using the TableName to resolve the correct column. This is the SQL Lightspeed generates for the Query (getById): exec sp_executesql N'SELECT [Body].[Id] AS [Body.Id], [Body].[EntityType] AS [Body.EntityType], [AAAA].[CirtsId] AS [AAAA.CirtsId], [AAAA].[CountryId] AS [AAAA.CountryId], [BBBB].[CirtsId] AS [BBBB.CirtsId], [BBBB].[CountryId] AS [BBBB.CountryId], [CCCC].[ATSIId] AS [CCCC.ATSIId], [CCCC].[ATSIOtherDetail] AS [CCCC.ATSIOtherDetail], [CCCC].[Alias] AS [CCCC.Alias], FROM [Cirts].[Body] LEFT OUTER JOIN [Cirts].[AAAA] [AAAA] ON [Body].[Id] = [AAAA].[Id] LEFT OUTER JOIN [Cirts].[BBBB] [BBBB] ON [Body].[Id] = [BBBB].[Id] LEFT OUTER JOIN [Cirts].[CCCC] [CCCC] ON [Body].[Id] = [CCCC].[Id] WHERE ([Body].[Id] = @p0 AND [AAAA].[DeletedOn] IS NULL); As a workaround is there anyway to get the SQL pared down to select from the base and just the specific derived table ?
Thanks! |
|
|
The workaround you suggest is not currently possible. The workaround is to use different names for the properties in the two parts of the hierarchy, e.g. Aaaa.AaaaCirtsId and Bbbb.BbbbCirtsId, and map them to the desired column names using the Column Name setting (or the ColumnAttribute for hand-coded entities). |
|