nein-linq
nein-linq copied to clipboard
[Question/Feature Request] Overwrite member/property mapping
Hi, I'm having some problems with reusing expressions and stumbled upon this really nice library!
Now I wonder if the following is already possible with NeinLinq and if not if it would be possible to implement (I guess it might be tricky).
I have a DTO class that is display in a list, some of the properties in the DTO should be featched from diffrent places depending on selections of the users so I have done this now:
public class DTO
{
public Guid Id {get;set;}
public string Name {get;set;}
public string ExtendedName {get;set;}
}
Expression<Func<Education, StaticEducation, DTO>> base = (e, _) => new DTO { Id = e.Id, Name = e.Name};
Expression<Func<Education, StaticEducation, DTO>> extended = (e, es) => new DTO { ExtendedName = es.Name};
var combined = base.Apply(extended);
This works but I would like to do this: Override the first Name mapping with the second one like this:
public class DTO
{
public Guid Id {get;set;}
public string Name {get;set;}
}
Expression<Func<Education, StaticEducation, DTO>> base = (e, _) => new DTO { Id = e.Id, Name = e.Name};
Expression<Func<Education, StaticEducation, DTO>> extended = (e, es) => new DTO { Name = es.Name};
//Here Id is from Education and Name is from StaticEducation
var combined = base.Apply(extended);
So my two questions:
- Is this possible with NeinLinq today somehow? (I have looked long at the documentation and code but could not figure it out)
- If not would it be hard to implement as a feature?
This isn't possible at the moment, but shouldn't be that hard to implement.
I can look into that.