public void Update(CountyDal county) { using (var conn = Database.GetConnection()) { conn.Execute("update Counties set county_name=@name where id=@id;", new { id = county.Id, name = county.Name }); } }
public int Insert(CountyDal county) { using (var conn = Database.GetConnection()) { conn.Execute("insert into Counties (county_name) values (@name);", new { name = county.Name }); var result = conn.Query <CountyDal>("select id, county_name AS name from Counties where name=@name;", county.Name).FirstOrDefault(); return(result == null ? -1 : result.Id); } }