Skip to content

Projection does not call call Map() #318

@AllanMichaelsen

Description

@AllanMichaelsen

When mapping an EF Entity with projection, the Map() method is not called.

    public static Expression<Func<global::UnitEntity, UnitDto>> Projection =>
        source => new UnitDto
        {
            Id = source.Id,
            ...
        };

The constructors do call the Map()

    public UnitDto(global::UnitEntity source, int __depth, System.Collections.Generic.HashSet<object>? __processed)
    {
        this.Id = source.Id;
        ...
        global::UnitDtoMapConfig.Map(source, this);
    }

Would it not be more maintainable if the Projection() method called the Constructor?

    public static Expression<Func<global::UnitEntity, UnitDto>> Projection =>
        source => new UnitDto(source, 0, new System.Collections.Generic.HashSet<object>(System.Collections.Generic.ReferenceEqualityComparer.Instance));

That way there is only one set of generated code, and the linearity of the projection (imho) seems more direct. Not sure how this would go with the projection and pulling all the needed includes :-)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions