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