Skip to content
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

[Question/Feature Request] Overwrite member/property mapping #37

Closed
SpaceOgre opened this issue Sep 21, 2022 · 1 comment
Closed

[Question/Feature Request] Overwrite member/property mapping #37

SpaceOgre opened this issue Sep 21, 2022 · 1 comment

Comments

@SpaceOgre
Copy link

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:

  1. Is this possible with NeinLinq today somehow? (I have looked long at the documentation and code but could not figure it out)
  2. If not would it be hard to implement as a feature?
@SpaceOgre SpaceOgre changed the title [Question/Feature Request] [Question/Feature Request] Overwrite member/property mapping Sep 21, 2022
@axelheer
Copy link
Owner

This isn't possible at the moment, but shouldn't be that hard to implement.

I can look into that.

@axelheer axelheer closed this as completed Dec 7, 2023
@axelheer axelheer closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants