public int Insert(SqlDapperHelper db) { if (string.IsNullOrWhiteSpace(TITLE)) { throw new Exception("제목은 빈값일 수 없습니다"); } string sql = @" INSERT INTO dbo.T_BOARD ( SEQ ,TITLE ,CONTENTS ,REG_U_ID ,REG_NAME ,REG_DATE ,STATUS ) SELECT ISNULL((SELECT MAX(SEQ)+1 FROM dbo.T_BOARD), 1) ,@TITLE ,@CONTENTS ,@REG_U_ID ,@REG_NAME ,@REG_DATE ,@STATUS "; return(db.Execute(sql, this)); }
public int DeleteByIds(List <long> ids) { if (ids.Count == 0) { return(0); } string sql = "DELETE FROM [examtotalcount_without] WHERE [id] IN @ids"; return(SqlDapperHelper.Execute(sql, new { ids = ids })); }
public int DeleteByIds(List <int> ids) { if (ids.Count == 0) { return(0); } string sql = "DELETE FROM [admins] WHERE EXISTS(SELECT 1 FROM @table as t WHERE t.id=[admins].[id])"; return(SqlDapperHelper.Execute(sql, new { table = ids.AsTableValuedParameter("type_int") })); }
public int UpdateAll(adminsTable entity, string updateFields = null) { if (updateFields == null) { updateFields = "[username]=@username,[pwd]=@pwd,[sex]=@sex"; } else { updateFields = StringHelper.SqlUpdateFields(updateFields); } string sql = "UPDATE [admins] SET " + updateFields; return(SqlDapperHelper.Execute(sql, entity)); }
public int UpdateAll(examTable entity, string updateFields = null) { if (updateFields == null) { updateFields = "[school_id]=@school_id,[schoolyear_nowyear]=@schoolyear_nowyear,[schoolyear_mester]=@schoolyear_mester,[grade_section]=@grade_section,[exam_name]=@exam_name,[exam_time]=@exam_time,[exam_level]=@exam_level"; } else { updateFields = StringHelper.SqlUpdateFields(updateFields); } string sql = "UPDATE [exam] SET " + updateFields; return(SqlDapperHelper.Execute(sql, entity)); }
public int UpdateAll(examtotalcount_withoutTable entity, string updateFields = null) { if (updateFields == null) { updateFields = "[exam_id]=@exam_id,[grade_class]=@grade_class,[exam_subject]=@exam_subject,[exam_avg]=@exam_avg,[exam_stdevp]=@exam_stdevp,[exam_max]=@exam_max,[exam_allpassnum]=@exam_allpassnum,[exam_onepassnum]=@exam_onepassnum,[exam_twopassnum]=@exam_twopassnum,[exam_threepassnum]=@exam_threepassnum,[exam_greatnum]=@exam_greatnum,[exam_passnum]=@exam_passnum,[exam_allrank]=@exam_allrank,[exam_onerank]=@exam_onerank,[exam_tworank]=@exam_tworank,[exam_threerank]=@exam_threerank"; } else { updateFields = StringHelper.SqlUpdateFields(updateFields); } string sql = "UPDATE [examtotalcount_without] SET " + updateFields; return(SqlDapperHelper.Execute(sql, entity)); }
public int UpdateFieldsByWhere(adminsTable entity, string whereFields, string updateFields = null) { if (updateFields == null) { updateFields = "[username]=@username,[pwd]=@pwd,[sex]=@sex"; } else { updateFields = StringHelper.SqlUpdateFields(updateFields); } string where = "WHERE " + StringHelper.SqlWhereFields(whereFields); string sql = string.Format("UPDATE [admins] SET {0} " + where, updateFields); return(SqlDapperHelper.Execute(sql, entity)); }
public int UpdateFieldsByWhere(examtotalcount_withoutTable entity, string whereFields, string updateFields = null) { if (updateFields == null) { updateFields = "[exam_id]=@exam_id,[grade_class]=@grade_class,[exam_subject]=@exam_subject,[exam_avg]=@exam_avg,[exam_stdevp]=@exam_stdevp,[exam_max]=@exam_max,[exam_allpassnum]=@exam_allpassnum,[exam_onepassnum]=@exam_onepassnum,[exam_twopassnum]=@exam_twopassnum,[exam_threepassnum]=@exam_threepassnum,[exam_greatnum]=@exam_greatnum,[exam_passnum]=@exam_passnum,[exam_allrank]=@exam_allrank,[exam_onerank]=@exam_onerank,[exam_tworank]=@exam_tworank,[exam_threerank]=@exam_threerank"; } else { updateFields = StringHelper.SqlUpdateFields(updateFields); } string where = "WHERE " + StringHelper.SqlWhereFields(whereFields); string sql = string.Format("UPDATE [examtotalcount_without] SET {0} " + where, updateFields); return(SqlDapperHelper.Execute(sql, entity)); }
public int UpdateFieldsByWhere(examTable entity, string whereFields, string updateFields = null) { if (updateFields == null) { updateFields = "[school_id]=@school_id,[schoolyear_nowyear]=@schoolyear_nowyear,[schoolyear_mester]=@schoolyear_mester,[grade_section]=@grade_section,[exam_name]=@exam_name,[exam_time]=@exam_time,[exam_level]=@exam_level"; } else { updateFields = StringHelper.SqlUpdateFields(updateFields); } string where = "WHERE " + StringHelper.SqlWhereFields(whereFields); string sql = string.Format("UPDATE [exam] SET {0} " + where, updateFields); return(SqlDapperHelper.Execute(sql, entity)); }
public int Update(SqlDapperHelper db) { if (string.IsNullOrWhiteSpace(TITLE)) { throw new Exception("제목은 빈값일 수 없습니다"); } string sql = @" UPDATE dbo.T_BOARD SET TITLE = @TITLE ,CONTENTS = @CONTENTS ,REG_U_ID = @REG_U_ID ,REG_NAME = @REG_NAME ,REG_DATE = @REG_DATE ,STATUS = @STATUS ,UPDATE_DATE = getdate() WHERE SEQ = @SEQ "; return(db.Execute(sql, this)); }
public int DeleteAll() { string sql = "DELETE FROM [admins]"; return(SqlDapperHelper.Execute(sql)); }
public int InsertIdentity(adminsTable entity) { string sql = "SET IDENTITY_INSERT [admins] ON;INSERT INTO [admins] ([id],[username],[pwd],[sex]) VALUES (@id,@username,@pwd,@sex);SET IDENTITY_INSERT [admins] OFF"; return(SqlDapperHelper.Execute(sql, entity)); }
public int DeleteById(long id) { string sql = "DELETE FROM [examtotalcount_without] WHERE [id] = @id"; return(SqlDapperHelper.Execute(sql, new { id = id })); }
public int InsertIdentity(examtotalcount_withoutTable entity) { string sql = "SET IDENTITY_INSERT [examtotalcount_without] ON;INSERT INTO [examtotalcount_without] ([id],[exam_id],[grade_class],[exam_subject],[exam_avg],[exam_stdevp],[exam_max],[exam_allpassnum],[exam_onepassnum],[exam_twopassnum],[exam_threepassnum],[exam_greatnum],[exam_passnum],[exam_allrank],[exam_onerank],[exam_tworank],[exam_threerank]) VALUES (@id,@exam_id,@grade_class,@exam_subject,@exam_avg,@exam_stdevp,@exam_max,@exam_allpassnum,@exam_onepassnum,@exam_twopassnum,@exam_threepassnum,@exam_greatnum,@exam_passnum,@exam_allrank,@exam_onerank,@exam_tworank,@exam_threerank);SET IDENTITY_INSERT [examtotalcount_without] OFF"; return(SqlDapperHelper.Execute(sql, entity)); }
public int DeleteById(int id) { string sql = "DELETE FROM [admins] WHERE [id] = @id"; return(SqlDapperHelper.Execute(sql, new { id = id })); }
public int DeleteAll() { string sql = "DELETE FROM [examtotalcount_without]"; return(SqlDapperHelper.Execute(sql)); }
public int InsertIdentity(examTable entity) { string sql = "SET IDENTITY_INSERT [exam] ON;INSERT INTO [exam] ([id],[school_id],[schoolyear_nowyear],[schoolyear_mester],[grade_section],[exam_name],[exam_time],[exam_level]) VALUES (@id,@school_id,@schoolyear_nowyear,@schoolyear_mester,@grade_section,@exam_name,@exam_time,@exam_level);SET IDENTITY_INSERT [exam] OFF"; return(SqlDapperHelper.Execute(sql, entity)); }