Skip to content

EF.Property not mapped correctly #152

Closed
@Xriuk

Description

@Xriuk
public class TestProduct {
  // Empty, has shadow key named BrandId
}

public class TestProductDTO {
  public int Brand { get; set; }
}

void Test{
  var config = new MapperConfiguration(c =>
  {
    c.CreateMap<TestProduct, TestProductDTO>()
      .ForMember(p => p.Brand, c => c.MapFrom(p => EF.Property<int>(p, "BrandId")));
  });
  
  config.AssertConfigurationIsValid();
  var mapper = config.CreateMapper();
  
  var products = new List<TestProduct>() {
    new TestProduct { }
  }.AsQueryable();
  
  Expression<Func<TestProductDTO, bool>> expr = x => x.Brand == 2;
  var mappedExpression = mapper.MapExpression<Expression<Func<TestProduct, bool>>>(expr);
  // The expression above returns: x => EF.Property(p, "BrandId") == 2
}

I don't know if this happens for other "functions", apparently the parameter "p" does not get replaced by some visitor during the conversion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions