-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping expressions - CreateMappingExpressions<X, Y>() is missing? #1271
Comments
If you are trying to do If it's there, then there's also another extension method called Also if doing repository thing you might want to look at https://github.com/TylerCarlson1/Automapper.Collection. It does some things to help persist easier. |
@TylerCarlson1 I have a DataService wrapper on the Repository with the following method. TDto is what the consumer classes deals with, T is the local SQLite entities I pass down to the repository.
Problem is I can't convert the expressions and receive the above. I'll check the link you sent but I don't think it solves this problem, I don't use Queyrables, instead I have to work with AsyncTableQuery and the SQLiteAsyncCOnnection. For example my
|
Ok I see yea if you don't have IQueryable then UseAsDataSource isn't gong to help you. The functionality is there for 4.1.1 for expression mapping and UseAsDataSource. The only thing I can see that's wrong is that if you have a null for predicate or orderBy you need to check if null and then map them. In the code if you try to map expressions and the source is null you will definitely get an ArgumentNullException. Other than that it should work fine. |
Hmmm, predicate is not null, it's a very strange problem. Although orderby is null, I was having in mind to add the null check but I can't get there anyway. |
Can you give me a dump of the full exception then? |
@TylerCarlson1 I forgot to post the inner exception here is the complete exception stacktraces and messages.
Also I don't think this will work |
value(FlightKit.Data.Client.Sync.Services.WindReportLocalDataService+<>c__DisplayClass46_0).dto.ReportId You aren't passing the whole object over so it gets a null trying to get the dto value. So you would need to redo your predicate like so
instead of
|
It worked like a charm, I've seen this but didn't even think the cast is failing. Thanks a lot @TylerCarlson1. |
I guess classes consuming the dataservice will do the same thing and I will still get errors like this, do you have any suggestion working around this? @TylerCarlson1 |
I think what you can do is if you make your classes serializable they can then be passed over with the expression and executed as such. If somehow they are in the different namespaces between the two dlls you need to remove the full qualified name from the serialization before you de-serialize it, so that it works. IDK exactly but you are going to have to tinker with the transfer or something like that to get it to work with classes. |
I think the best at this point is to expose the domain to the predicates and the consumer class will actually filter the domain directly but receive DTOs. Also makes more sense to avoid filtering DTO properties that might not exist. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Based on this answer http://stackoverflow.com/a/7425211/122769 and the comment "They moved CreateMapExpression to
Mapper.Engine.CreateMapExpression<Cat, Dog>();
" in how to map expressions using Automapper and this blog post, http://ahmadreza.com/2014/09/automapper-and-mapping-expressions/ I'm supposed to find theMapper.Engine.CreateMapExpression<X, Y>()
generic method which I can't. I can find theMapper.Engine.CreateMapExpression(Type, Type)
method instead.Have in mind that I can't update to the latest version of Automapper due to incompatible PCL profile, I'm using Automapper 4.1.1.
Any ideas how to accomplish this?
Expression<Func<T, bool>> domainPredicate = Map<Expression<Func<T, bool>>>(predicate);
The exception I'm getting trying the above.
Configuration.
The text was updated successfully, but these errors were encountered: