/DocSrvQuartz_V2/DocSrv.Core/DaWordsrvstatus.auto.cs
C# | 298 lines | 217 code | 60 blank | 21 comment | 4 complexity | 2a111702d0a289ffb31bc732d043b622 MD5 | raw file
Possible License(s): LGPL-2.1
1#region DaWordsrvstatus 2/*---------------------------------------------------------------- 3// ????DaWordsrvstatus.cs 4// ??????Wordsrvstatus?????? 5// 6// 7// ?????2009-05-03 DtataAccess template . Ver 5.0.20090413 8// 9// ????? 10// ????? 11//----------------------------------------------------------------*/ 12using System; 13using System.Collections; 14using System.Collections.Generic; 15using System.Collections.ObjectModel; 16using System.Data; 17using System.Globalization; 18using System.Text; 19using System.Data.Common; 20using Microsoft.Practices.EnterpriseLibrary.Data; 21using Microsoft.Practices.EnterpriseLibrary.Data.Sql; 22 23using DocSrv.Model; 24 25 26namespace DocSrv.Dal 27{ 28 ///?????????,IWordsrvstatus ,???????DaBase? 29 ///DaBase????DbException???????? 30 public partial class DaWordsrvstatus:DaBase<MoWordsrvstatus> 31 { 32 #region SQL const 33 internal const string TABLE_COLUMNS=" TR_ID ,RC ,UPDATE_TIME ,DESCRIPTION "; 34 35 internal const string SQL_INSERT="INSERT INTO WORDSRVSTATUS ("+TABLE_COLUMNS+") VALUES (@TrId,@Rc,@UpdateTime,@Description)"; 36 internal const string SQL_SELECT="SELECT "+TABLE_COLUMNS+" FROM WORDSRVSTATUS "; 37 internal const string SQL_SELECT_ONE=SQL_SELECT+" WHERE TR_ID=@TrId"; 38 39 internal const string SQL_EXIST="SELECT COUNT(*) FROM WORDSRVSTATUS WHERE TR_ID=@TrId "; 40 internal const string SQL_UPDATE="UPDATE WORDSRVSTATUS SET RC=@Rc, UPDATE_TIME=@UpdateTime, DESCRIPTION=@Description WHERE TR_ID=@TrId"; 41 42 internal const string SQL_DELETE_DEFAULT = "DELETE FROM WORDSRVSTATUS "; 43 internal const string SQL_DELETE="DELETE FROM WORDSRVSTATUS WHERE TR_ID=@TrId"; 44 45 internal const string SQL_COUNT="SELECT COUNT(*) FROM WordSrvStatus"; 46 #endregion 47 48 #region Constructor 49 50 /// <summary> 51 /// ??????????????????????? 52 /// </summary> 53 public DaWordsrvstatus () 54 { 55 this.db=DatabaseFactory.CreateDatabase(); 56 } 57 /// <summary> 58 /// ?????databaseName?????? 59 /// </summary> 60 /// <param name="databaseName">??????????????</param> 61 public DaWordsrvstatus (string databaseName) 62 { 63 this.db = DatabaseFactory.CreateDatabase(databaseName); 64 } 65 66 public DaWordsrvstatus (Database db) 67 { 68 this.db = db; 69 } 70 71 #endregion 72 73 //???CRUD?????????????????? 74 75 #region ????? 76 77 protected override MoWordsrvstatus ConstructT() 78 { 79 return new MoWordsrvstatus(); 80 } 81 #endregion 82 83 84 85 #region Add?? Helper 86 87 ///build the command object.It never throw exception. 88 protected override DbCommand ConstructAddCommand(Database db) 89 { 90 DbCommand dbCommand = db.GetSqlStringCommand(SQL_INSERT); 91 92 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString); 93 db.AddInParameter(dbCommand,"Rc",DbType.Int32); 94 db.AddInParameter(dbCommand,"UpdateTime",DbType.DateTime); 95 db.AddInParameter(dbCommand,"Description",DbType.String); 96 return dbCommand; 97 } 98 protected override DbCommand ConstructAddCommand(Database db,MoWordsrvstatus entity) 99 { 100 DbCommand dbCommand=db.GetSqlStringCommand(SQL_INSERT); 101 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString,entity.PkId); 102 db.AddInParameter(dbCommand,"Rc",DbType.Int32,entity.Rc); 103 db.AddInParameter(dbCommand,"UpdateTime",DbType.DateTime,entity.UpdateTime); 104 db.AddInParameter(dbCommand,"Description",DbType.String,entity.Description); 105 return dbCommand; 106 } 107 108 protected override DbCommand PopulateAddCommandParameters(Database db,DbCommand addCmd,MoWordsrvstatus entity) 109 { 110 db.SetParameterValue(addCmd,"TrId",entity.PkId); 111 db.SetParameterValue(addCmd,"Rc",entity.Rc); 112 db.SetParameterValue(addCmd,"UpdateTime",entity.UpdateTime); 113 db.SetParameterValue(addCmd,"Description",entity.Description); 114 return addCmd; 115 } 116 117 protected override DbCommand PopulateAddCommandParameters(Database db,DbCommand addCmd,DataRow row) 118 { 119 db.SetParameterValue(addCmd,"TrId",row["TrId"]); 120 db.SetParameterValue(addCmd,"Rc",row["Rc"]); 121 db.SetParameterValue(addCmd,"UpdateTime",row["UpdateTime"]); 122 db.SetParameterValue(addCmd,"Description",row["Description"]); 123 return addCmd; 124 } 125 126 #endregion 127 128 #region Update?? Helper 129 130 protected override DbCommand ConstructUpdateCommand(Database db) 131 { 132 DbCommand dbCommand=db.GetSqlStringCommand(SQL_UPDATE); 133 db.AddInParameter(dbCommand,"Rc",DbType.Int32); 134 db.AddInParameter(dbCommand,"UpdateTime",DbType.DateTime); 135 db.AddInParameter(dbCommand,"Description",DbType.String); 136 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString); 137 138 return dbCommand; 139 } 140 protected override DbCommand ConstructUpdateCommand(Database db,MoWordsrvstatus entity) 141 { 142 DbCommand dbCommand=db.GetSqlStringCommand(SQL_UPDATE); 143 db.AddInParameter(dbCommand,"Rc",DbType.Int32,entity.Rc); 144 db.AddInParameter(dbCommand,"UpdateTime",DbType.DateTime,entity.UpdateTime); 145 db.AddInParameter(dbCommand,"Description",DbType.String,entity.Description); 146 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString,entity.PkId); 147 148 return dbCommand; 149 } 150 151 protected override DbCommand PopulateUpdateCommandParameters(Database db,DbCommand updateCmd,MoWordsrvstatus entity) 152 { 153 db.SetParameterValue(updateCmd,"Rc",entity.Rc); 154 db.SetParameterValue(updateCmd,"UpdateTime",entity.UpdateTime); 155 db.SetParameterValue(updateCmd,"Description",entity.Description); 156 db.SetParameterValue(updateCmd,"TrId",entity.PkId); 157 return updateCmd; 158 } 159 protected override DbCommand PopulateUpdateCommandParameters(Database db,DbCommand updateCmd,DataRow row) 160 { 161 db.SetParameterValue(updateCmd,"Rc",row["Rc"]); 162 db.SetParameterValue(updateCmd,"UpdateTime",row["UpdateTime"]); 163 db.SetParameterValue(updateCmd,"Description",row["Description"]); 164 db.SetParameterValue(updateCmd,"TrId",row["TrId"]); 165 return updateCmd; 166 } 167 168 protected override void PrepareDataAdapterCommand(Database db,out DbCommand dbInsertCommand, 169 out DbCommand dbUpdateCommand,out DbCommand dbDeleteCommand) 170 { 171 dbInsertCommand = db.GetSqlStringCommand(SQL_INSERT); 172 #region set insert cmd parameters 173 db.AddInParameter(dbInsertCommand, "TrId",DbType.AnsiString, "TR_ID", DataRowVersion.Current); 174 db.AddInParameter(dbInsertCommand, "Rc",DbType.Int32, "RC", DataRowVersion.Current); 175 db.AddInParameter(dbInsertCommand, "UpdateTime",DbType.DateTime, "UPDATE_TIME", DataRowVersion.Current); 176 db.AddInParameter(dbInsertCommand, "Description",DbType.String, "DESCRIPTION", DataRowVersion.Current); 177 #endregion 178 dbUpdateCommand = db.GetSqlStringCommand(SQL_UPDATE); 179 #region Set update cmd value parameters 180 db.AddInParameter(dbUpdateCommand, "Rc", DbType.Int32, "RC", DataRowVersion.Current); 181 db.AddInParameter(dbUpdateCommand, "UpdateTime", DbType.DateTime, "UPDATE_TIME", DataRowVersion.Current); 182 db.AddInParameter(dbUpdateCommand, "Description", DbType.String, "DESCRIPTION", DataRowVersion.Current); 183 #endregion 184 #region set update cmd pk where parameters 185 db.AddInParameter(dbUpdateCommand, "TrId", DbType.AnsiString, "TR_ID", DataRowVersion.Current); 186 #endregion 187 dbDeleteCommand = db.GetSqlStringCommand(SQL_DELETE); 188 #region set delete cmd pk where parameters 189 db.AddInParameter(dbDeleteCommand, "TrId", DbType.AnsiString, "TR_ID", DataRowVersion.Current); 190 #endregion 191 } 192 #endregion 193 194 #region Delete?? Helper 195 196 protected override DbCommand ConstructDeleteCommand(Database db) 197 { 198 DbCommand dbCommand=db.GetSqlStringCommand(SQL_DELETE); 199 200 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString); 201 202 return dbCommand; 203 } 204 protected override DbCommand ConstructDeleteCommand(Database db,MoWordsrvstatus entity) 205 { 206 DbCommand dbCommand=db.GetSqlStringCommand(SQL_DELETE); 207 208 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString,entity.PkId); 209 210 return dbCommand; 211 } 212 213 protected override DbCommand ConstructDeleteCommandForWhere(Database db, string where) 214 { 215 return db.GetSqlStringCommand(SQL_DELETE_DEFAULT + where); 216 } 217 218 protected override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, MoWordsrvstatus entity) 219 { 220 db.SetParameterValue(deleteCmd,"TrId",entity.PkId); 221 return deleteCmd; 222 } 223 224 protected override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, DataRow row) 225 { 226 db.SetParameterValue(deleteCmd,"TrId",row["TrId"]); 227 return deleteCmd; 228 } 229 230 #endregion helper 231 232 #region Query?? Helper 233 234 protected override DbCommand ConstructQueryCommand(string condition) 235 { 236 return db.GetSqlStringCommand(SQL_SELECT + condition); 237 } 238 239 #endregion 240 241 #region GetEntity(s)?? Helper 242 243 protected override DbCommand ConstructSelectOneCommand(Database db,MoWordsrvstatus entity) 244 { 245 DbCommand dbCommand=db.GetSqlStringCommand(SQL_SELECT_ONE); 246 247 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString,entity.PkId); 248 return dbCommand; 249 } 250 251 protected override void PopulateEntityByDataReader(IDataReader reader,ref MoWordsrvstatus entity) 252 { 253 if (!reader.IsDBNull(0)) entity.PkId = reader.GetString(0); 254 if (!reader.IsDBNull(1)) entity.Rc = reader.GetInt32(1); 255 if (!reader.IsDBNull(2)) entity.UpdateTime = reader.GetDateTime(2); 256 if (!reader.IsDBNull(3)) entity.Description = reader.GetString(3); 257 } 258 259 260 261 protected override DbCommand ConstructSelectConditionCommand(Database db, string condition) 262 { 263 return db.GetSqlStringCommand(SQL_SELECT + condition); 264 } 265 266 #endregion 267 268 #region Count?? Helper 269 270 protected override DbCommand ConstructCountCommand(Database db) 271 { 272 return db.GetSqlStringCommand(SQL_COUNT); 273 } 274 275 protected override DbCommand ConstructCountConditionCommand(Database db, string condition) 276 { 277 return db.GetSqlStringCommand(SQL_COUNT + condition); 278 } 279 280 #endregion 281 282 #region IsExist?? Helper 283 284 protected override DbCommand ConstructIsExistCommand(Database db, MoWordsrvstatus entity) 285 { 286 DbCommand dbCommand = db.GetSqlStringCommand(SQL_EXIST); 287 db.AddInParameter(dbCommand,"TrId",DbType.AnsiString,entity.PkId); 288 return dbCommand; 289 } 290 291 #endregion 292 293 294 295 } 296} 297#endregion 298