The Runtime Framework, linq, dto projection

Posts   
 
    
botekl
User
Posts: 2
Joined: 10-Oct-2017
# Posted on: 27-Aug-2018 12:09:29   

Hello,

please I need help with this query.

            var data = Task.Run(() => metaData.Map
                          .Where(m => m.Id == id)
                         .Include(m => m.MapDetails)
                            .ThenInclude(md => md.Indicators)
                         .Include(m => m.MapDetails)
                            .ThenInclude(md => md.Measures)
                         .Include(m => m.DefaultUnitOfMeasureId)
                         .FirstOrDefault()).Result;

return data.ProjectToLocalesMap(); => not implemented exception

Problem is, when I try return single row and model is relational ... see Include. Also in derived classes I have included that relations.

Thanks Lubomir

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Aug-2018 22:50:34   

Could you please post the stackTrace? Also please try without Task.Run()

botekl
User
Posts: 2
Joined: 10-Oct-2017
# Posted on: 28-Aug-2018 09:08:10   

I tried couple of scenarios, code without task.run was also there

Stack Trace: at lambda_method(Closure , MapEntity ) at LocalesDerivedModel.Persistence.LocalesMapPersistence.ProjectToLocalesMap(MapEntity entity) in C:\sourcecode\Kline\Kline.Database\Kline.Database.Data\LocalesDerivedModel.Persistence\LocalesMapPersistence.cs:line 35 at Kline.Database.Data.InternalSources.MapData.GetMapDataById(Int64 id) in C:\sourcecode\Kline\Kline.Database\Kline.Database.Data\LocalesData\MapData.cs:line 86 at Kline.Database.Locales.Controllers.MapController.Detail(Int64 id, Nullable`1 unitOfMeasureId, String searchCriteria) in C:\sourcecode\Kline\Kline.Database\Locales\Controllers\MapController.cs:line 50 at lambda_method(Closure , Object , Object[] ) at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()

Message: Object reference not set to an instance of an object.

Exception: {System.NullReferenceException: Object reference not set to an instance of an object. at lambda_method(Closure , MapEntity ) at LocalesDerivedModel.Persistence.LocalesMapPersistence.ProjectToLocalesMap(MapEntity entity) in C:\sourcecode\Kline\Kline.Database\Kline.Database.Data\LocalesDerivedModel.Persistence\LocalesMapPersistence.cs:line 35 at Kline.Database.Data.InternalSources.MapData.GetMapDataById(Int64 id) in C:\sourcecode\Kline\Kline.Database\Kline.Database.Data\LocalesData\MapData.cs:line 86 at Kline.Database.Locales.Controllers.MapController.Detail(Int64 id, Nullable`1 unitOfMeasureId, String searchCriteria) in C:\sourcecode\Kline\Kline.Database\Locales\Controllers\MapController.cs:line 50 at lambda_method(Closure , Object , Object[] ) at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()}

Attachments
Filename File size Added on Approval
LLBLGen Pro Error.PNG 94,493 28-Aug-2018 09:08.30 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 28-Aug-2018 18:26:47   

if you project a graph in memory to a DTO graph, this could happen if an expected navigator is null. The generated projection methods are designed to be used with database targets and if possible with in-memory targets but there's no null check (as the projector is shared with the database variant which doesn't need it) so this could happen if a navigator is null (e..g order.Customer is null ). This is a known issue and there's no work around at the moment other than to copy the generated method and alter it to add the null check (so copy the code to a file that's not generated) to the copied method so it won't fail.

This is scheduled to be addressed in a future version.

Frans Bouma | Lead developer LLBLGen Pro