예제 #1
0
 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 });
     }
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        protected override void DataPortal_Update()
        {
            var dal = new Dal.Schools();

            using (BypassPropertyChecks)
            {
                var data = new Dal.SchoolDal {
                    Id = Id, Name = Name
                };
                dal.Update(data);
            }
        }
예제 #4
0
        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;
            }
        }