/DocSrvQuartz_V2/DocSrv.Core/DaWordsrvstatus.auto.cs

http://sgsoft-las.googlecode.com/ · C# · 298 lines · 217 code · 60 blank · 21 comment · 4 complexity · 2a111702d0a289ffb31bc732d043b622 MD5 · raw file

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