Replies: 2 comments 4 replies
-
May be make the problem more narrow. If your configuration is: CreateMap<Entity.User, Model.User>()
.ForMember(dest => dest.Id, opts => opts.MapFrom(src => src.Id))
.ForMember(dest => dest.IdentityId, opts => opts.MapFrom(src => src.IdentityId))
.ForMember(dest => dest.Identity, opts => opts.Ignore()); What should be the result from mapping this expression I think Make sense? |
Beta Was this translation helpful? Give feedback.
1 reply
-
It sounds like you want the URL to indicate expansion but for the library to ignore it? Then you probably need to create your own extension methods to do this without the includes (or even earlier). I think it would be an odd use case to add to the library. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there,
Hoping this is the most appropriate place to start the conversation between this repo and AutoMapper.Extensions.ExpressionMapping!
I'm doing something probably a bit outside the norm. I'm aggregating two datasources behind an OData API. My database has Users and each User has its respective Identity in Azure B2C.
Currently, my application fetches Users from an OData API and then will separately fetch the Identity from B2C using the resulting User's IdentityId. I'd like to update my API to abstract B2C away from my application and add Identity to my User model. This would allow my application to request a User and optionally include its Identity with
$expand=Identity
and the details of how or where that Identity comes from can be a concern of the User API.So, imagine this pretty slimmed-down example of my model:
Model.Identity
- OOdata model (first/last name, email, etc)Microsoft.Graph.User
- record in B2C via graph API, mapped toModel.Identity
Model.User
- OData model, has aModel.Identity
, roles, tenant assignment, other customer-specific stuffEntity.User
- EFCore entity mapped toModel.User
AutoMapper profile:
My OData model:
In my controller I might do something like:
And yes, I'm definitely thinking about the complexity this can open up, if clients ever want to query for Users and then do something like
$filter=Identity/Email eq 'whatever'
but just including the Identity as a starting point and not worrying about supporting$filter
would be a big win here.When I run a query with the above setup and specify
$expand=Identity
I get an error:My expected (desired) behavior would be for AutoMapper to ignore the
Model.User.Identity
property and not try to map it to an include statement when generating the expression for EF Core.Not sure if I'm relating the right section of the docs, but I thought
Ignore
would be a supported operation Maybe that's only respected for simple properties and not navigation properties and/or when generating.Include(...)
statements? Just wondering if I can configure things differently or if someone can provide some insight into what I'm seeing.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions