I have a varchar key column. I am trying to use the Get
method of Dapper contrib. I get an exception:
Get only supports an entity with a [Key] or an [ExplicitKey] property.
My Entity:
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; }
}
My Dapper Method
public IEnumerable<State> FindByCode(string code)
{
return this._db.Get<State>(code);
}
I even tried to set Explicit Key, still I get the same error. What am I doing wrong?
Try to check your code like: