-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Description
I'm buildning a library of Select Expressions for our product and have found that I would like to do something like this:
internal static class MapperDTO
{
internal static Expression<Func<Subject, EducationEvent, PeriodData, MyDTO>> ToDTO =>
(subject, educationEvent, periodData) => new MyDTO
{
FolkbokforingskommunName = periodData == null ? subject.Folkbokforingskommun.Name : periodData.Municipality.Name,
};
}
This is then Invoked and Expanded with LinqKit and passed down to Entity Framework.
Expression<Func<EducationEvent, MyDTO>> mapper =
educationEvent => MapperForDTO.ToDTO.Invoke(educationEvent.Subject, educationEvent, null);
Obviously this does not work since null is not allowed for non-static parameters (even static?) but I have looked at the expression tree and this does create an IIF condition that looks like this:
IIF(null == null, subject.Folkbokforingskommun.Name, null.Municipality.Name)
Would it be much work to eliminate the IIF and just replace it with the correct branching?
Metadata
Metadata
Assignees
Labels
No labels