Closed jornhd closed 4 years ago
That sounds like a bug - I'll check it out. Thanks for letting me know!
Steve
Hi!
I've had a go and been unable to reproduce this - here's a fiddle which successfully maps using GetService<>
.
Could you share exactly what you're trying to map, please?
All the best,
Steve
Modified your fiddle, and now get the same error: https://dotnetfiddle.net/4XzT0u
I've had a look into this, and while I haven't yet figured out the error you're getting (which I'll find and sort out, cos I at least want it to fail gracefully), there is an issues with what you're trying to do.
Query Projection creates a mapping expression which is transformed by an underlying QueryProvider - EntityFramework, for example - into SQL. Because the mapping is applied via the QueryProvider, AgileMapper only applies configurations which can be supported in SQL - values obtained from injected services would not be supported, and configurations setting those up will be ignored in projections.
This is fixed in the current 1.7.2 release branch - injected service values are now filtered out of query projections.
Thanks again for letting me know!
This is fixed in release 1.7.2, which is now on NuGet.
Thanks again!
AgileMapper Version 1.7.1 I'm having problems when trying to use an injected service in member mapping. Using .NET core 3.1, I've setup the service provider in public static void Configure(IApplicationBuilder app):
This seems to work fine as I get a logger message in mapping configuration:
I've tried this from the documentation:
But this results in the following exception.
System.InvalidOperationException: variable 'i' of type 'System.Int32' referenced from scope '', but it is not defined at System.Linq.Expressions.Compiler.VariableBinder.Reference(ParameterExpression node, VariableStorageKind storage)
So.. I'm I doing something wrong, or is this a bug?