0

控制台应用程序要点中的完整示例

我有一些具有计算只读属性的实体。

这是我的 Automapper 映射配置来计算属性。

cfg.CreateMap(t, t).ForMember(nameof(ITestInterface.IsReadOnly), opt => opt.MapFrom(src => ((ITestInterface)src).OrganizationUnitId == ((ITestInterface)src).TenantId));

这是一个抛出异常的简单查询

var simpleQuery = from super in context.SuperEntities.AsQueryable().ProjectTo<SuperEntity>()
                          join other in context.OtherSuperEntities.AsQueryable().ProjectTo<OtherSuperEntity>() on super.Id equals other.SuperEntityId
                          select new { super.IsReadOnly, other.OtherSuperDescription };
        var simpleResult = simpleQuery.ToList();

我收到 InvalidOperationException:读取属性“OtherSuperEntity.Id”的数据库值时发生异常。预期类型为“System.Int64”,但实际值为“System.Boolean”类型。

这是自动映射器的问题吗?他们刚刚关闭了我的问题

4

0 回答 0