我是新手Dapper
和Dapper.Contrib
。有一个这样的类,并且数据库中有一个同名的表:
public class Ware
{
public int ID { get; set; }
public string Name { get; set; }
public short UnitID { get; set; }
public short TypeID { get; set; }
public int CableCodeID { get; set; }
public string Tag1 { get; set; }
public string Tag2 { get; set; }
public bool Discontinued { get; set; }
public decimal Stock { get; set; } //this is not in database. this is helper
public string UnitCaption { get; set; } //this is not in database. this is helper
public string TypeCaption { get; set; } //this is not in database. this is helper
public string FullCaption //this is not in database. this is helper
{
get
{
return $"{ID} {Name}";
}
}
}
我需要将此类的整个列表更新到数据库。我用:
conection.Update(myList); // myList is List<Ware>
但是运行的时候报错:
System.Data.SqlClient.SqlException: 'Invalid column name 'Stock'.'
System.Data.SqlClient.SqlException: 'Invalid column name 'UnitCaption'.'
System.Data.SqlClient.SqlException: 'Invalid column name 'TypeCaption'.'
System.Data.SqlClient.SqlException: 'Invalid column name 'FullCaption'.'
如何解决这个问题?