public MyClass Add(MyClass myClass) { string sql ="INSERT INTO MyClass (className) output inserted.classId VALUES (@className)"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@className", ToDBValue(myClass.ClassName)), }; int newId = (int)SqlHelper.ExecuteScalar(sql, para); return GetByClassId(newId); }
public int Update(MyClass myClass) { string sql = "UPDATE MyClass " + "SET " + " className = @className" +" WHERE classId = @classId"; SqlParameter[] para = new SqlParameter[] { new SqlParameter("@classId", myClass.ClassId) ,new SqlParameter("@ClassName", ToDBValue(myClass.ClassName)) }; return SqlHelper.ExecuteNonQuery(sql, para); }
public int Update(MyClass myClass) { return new MyClassDAL().Update(myClass); }
public MyClass ToModel(SqlDataReader reader) { MyClass myClass = new MyClass(); myClass.ClassId = (int)ToModelValue(reader,"classId"); myClass.ClassName = (string)ToModelValue(reader,"className"); return myClass; }
public MyClass Add(MyClass myClass) { return new MyClassDAL().Add(myClass); }