我有一个 varchar 键列。我正在尝试使用Get
Dapper contrib 的方法。我得到一个例外:
Get 仅支持具有 [Key] 或 [ExplicitKey] 属性的实体。
我的实体:
public class State : BaseModel
{
[Key]
public string state_code { get; set; }
public string state_name { get; set; }
public int language_code { get; set; }
public bool is_active { get; set; }
}
我的精巧方法
public IEnumerable<State> FindByCode(string code)
{
return this._db.Get<State>(code);
}
我什至尝试设置显式密钥,但仍然出现相同的错误。我究竟做错了什么?