public void Update(SchoolDal school) { using (var conn = Database.GetConnection()) { conn.Execute("update Schools set school_name=@name where id=@id;", new { id = school.Id, name = school.Name }); } }
public int Insert(SchoolDal school) { using (var conn = Database.GetConnection()) { conn.Execute("insert into Schools (school_name) values (@name);", new { name = school.Name }); var result = conn.Query <SchoolDal>("select id, school_name AS name from Schools where school_name=@name;", new { name = school.Name }).FirstOrDefault(); return(result == null ? -1 : result.Id); } }
protected override void DataPortal_Update() { var dal = new Dal.Schools(); using (BypassPropertyChecks) { var data = new Dal.SchoolDal { Id = Id, Name = Name }; dal.Update(data); } }
protected override void DataPortal_Insert() { var dal = new Dal.Schools(); using (BypassPropertyChecks) { var data = new Dal.SchoolDal { Name = Name }; var newId = dal.Insert(data); Id = newId; } }