1

我使用 DapperExtensions 库进行简单的 CRUD 操作。当我向模型添加导航属性时,我收到一条错误消息,指出该列不在数据库中。你能以任何方式改变它,让 Dapper Extensions 忽略这个属性吗?

我的模型示例

public class Order : EntityBase
{
    public int OrderId { get; set; }
    public int MarketId { get; set; }
    public int ModelId { get; set; }
    public int ContactId { get; set; }
    public string Project { get; set; }
    public decimal Undertaking { get; set; }

    public virtual Model Model { get; set; }
    public virtual Contact Contact { get; set; }
}
4

2 回答 2

2

使用属性上方的 Write 属性

[Write(false)]
于 2013-02-01T15:16:11.457 回答
1
  1. 添加 dapperextensions 的包
  2. 自动地图();只要您具有相同的字段名称,就会映射所有其他属性。
public class CustomMapper : DapperExtensions.Mapper.ClassMapper<Photo>
    {
        public CustomMapper()
        {
           Table("TableName if diffrent than the Model calss name");
           Map(f => f.SomePropertyIDontCareAbout).Ignore();
           AutoMap();
        }
    }
于 2020-11-06T14:12:37.797 回答