-
Notifications
You must be signed in to change notification settings - Fork 328
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
Proposal - ProjectToType as NonGeneric #260
Comments
I think If your type is dynamic, for now Mapster doesn't support your use case. The closest, you can call |
No dynamics, I expressed the idea poorly. I meant projection to types unknown at design time in order to provide flexibility and segregation between the query and the projection. The example was also expressed poorly :) 2 for 2 I'm on a roll. Imagine a scenario where you have a web api that performs a query and the return result can be any of the possible projections for the type being queried, something like: public ActionResult Get(int projectionToken)
{
Type projectionType = GetProjectionType(projectionToken);
if(projectionType != null)
{
IEnumerable<object> result = someDbContext.SomeDbSet.ProjectToType(projectionType);
return Ok(result);
}
return BadRequest();
} If I understood correctly your idea would be: var config = new TypeAdapterConfig().NewConfig(typeof(Source), typeof(Destination));
var lambda = config.Config.CreateMapExpression(new TypeTuple(typeof(Source), typeof(Destination)), MapType.Projection);
var projection = someDbContext.SomeDbSet.AsQueryable().Provider.CreateQuery(lambda);
var result = projection.Cast<object>().ToList(); This is what I envision to be under the hood :) |
Hello,
IMHO it would add great value to your library if one could use
ProjectoToType
with the following:This is already possible with the Adapt method.
This would allow for, i.e., dynamic api requests mapped straight in the projection.
Let me know if you think this to be useful?
The text was updated successfully, but these errors were encountered: