kamagra how much to take

AspnetSchemaversionsDTO Partial Class

A partial data object class for the “Schemaversions” table in the ASP.NET 2.0 provider database. The relevant data transfer objects contain only the serializable data of a data object.

  1.  //*****************************************************************************
  2. // This file is part of the data access layer example to the ASP.NET 2.0 provider database
  3. // This file was written by Adam Buenz [WSS MVP] of ARB Security Solutions, LLC
  4. // http://www.sharepointsecurity.com
  5. //
  6. // This file and its parts is free for re-distribution, for use in both free
  7. // and commercial applications, however this header must remain intact for legal
  8. // use. The data access layer example is distributed in the hope that it will
  9. // be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. //*****************************************************************************
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.Data.SqlClient;
  16. using Aspnet.Provider.Datalayer.Commands;
  17. using Aspnet.Provider.Datalayer.DataTransferObjects;
  18.  
  19. namespace Aspnet.Provider.Datalayer
  20. {
  21. ///
  22. /// The AspnetUsers class.
  23. ///
  24. public partial class AspnetUsers : IPersistable
  25. {
  26. #region Members
  27.  
  28. private bool isNew;
  29. private bool _isNew;
  30. private Guid applicationid;
  31. private Guid userid;
  32. private string username;
  33. private string loweredusername;
  34. private string mobilealias;
  35. private bool isanonymous;
  36. private DateTime lastactivitydate;
  37.  
  38. #endregion
  39.  
  40. #region Properties
  41.  
  42. ///
  43. /// The Applicationid.
  44. ///
  45. public virtual Guid Applicationid
  46. {
  47. get { return this.applicationid; }
  48. set { this.applicationid = value; }
  49. }
  50.  
  51. ///
  52. /// The Userid.
  53. ///
  54. public virtual Guid Userid
  55. {
  56. get { return this.userid; }
  57. set { this.userid = value; }
  58. }
  59.  
  60. ///
  61. /// The Username.
  62. ///
  63. [StringInfo(256, true)]
  64. public virtual string Username
  65. {
  66. get { return this.username; }
  67. set { this.username = value; }
  68. }
  69.  
  70. ///
  71. /// The Loweredusername.
  72. ///
  73. [StringInfo(256, true)]
  74. public virtual string Loweredusername
  75. {
  76. get { return this.loweredusername; }
  77. set { this.loweredusername = value; }
  78. }
  79.  
  80. ///
  81. /// The Mobilealias.
  82. ///
  83. [StringInfo(16, false)]
  84. public virtual string Mobilealias
  85. {
  86. get { return this.mobilealias; }
  87. set { this.mobilealias = value; }
  88. }
  89.  
  90. ///
  91. /// The Isanonymous.
  92. ///
  93. public virtual bool Isanonymous
  94. {
  95. get { return this.isanonymous; }
  96. set { this.isanonymous = value; }
  97. }
  98.  
  99. ///
  100. /// The Lastactivitydate.
  101. ///
  102. public virtual DateTime Lastactivitydate
  103. {
  104. get { return this.lastactivitydate; }
  105. set { this.lastactivitydate = value; }
  106. }
  107.  
  108. #endregion
  109.  
  110. #region ColumnNames
  111.  
  112. ///
  113. /// The corresponding schema name.
  114. ///
  115. internal const string SchemaName = "dbo";
  116.  
  117. ///
  118. /// The corresponding table name.
  119. ///
  120. internal const string TableName = "aspnet_Users";
  121.  
  122. ///
  123. /// The column names.
  124. ///
  125. internal class ColumnNames
  126. {
  127. ///
  128. /// The column name of the Applicationid property.
  129. ///
  130. public const string Applicationid="ApplicationId";
  131. ///
  132. /// The column name of the Userid property.
  133. ///
  134. public const string Userid="UserId";
  135. ///
  136. /// The column name of the Username property.
  137. ///
  138. public const string Username="UserName";
  139. ///
  140. /// The column name of the Loweredusername property.
  141. ///
  142. public const string Loweredusername="LoweredUserName";
  143. ///
  144. /// The column name of the Mobilealias property.
  145. ///
  146. public const string Mobilealias="MobileAlias";
  147. ///
  148. /// The column name of the Isanonymous property.
  149. ///
  150. public const string Isanonymous="IsAnonymous";
  151. ///
  152. /// The column name of the Lastactivitydate property.
  153. ///
  154. public const string Lastactivitydate="LastActivityDate";
  155. }
  156.  
  157. #endregion
  158.  
  159. ///
  160. /// The default constructor.
  161. ///
  162. public AspnetUsers()
  163. {
  164. this.isNew = true;
  165. PersistenceManager.InvokeInstanceMethod(this, "CreationComplete", null);
  166. }
  167.  
  168. ///
  169. /// The constructor of the required fields.
  170. ///
  171. ///
  172. The Applicationid. ///
  173. The Userid. ///
  174. The Username. ///
  175. The Loweredusername. ///
  176. The Isanonymous. ///
  177. The Lastactivitydate. public AspnetUsers(Guid applicationid, Guid userid, string username, string loweredusername, bool isanonymous, DateTime lastactivitydate)
  178. {
  179. this.applicationid = applicationid;
  180. this.userid = userid;
  181. this.username = username;
  182. this.loweredusername = loweredusername;
  183. this.isanonymous = isanonymous;
  184. this.lastactivitydate = lastactivitydate;
  185.  
  186. this.isNew = true;
  187. PersistenceManager.InvokeInstanceMethod(this, "CreationComplete", null);
  188. }
  189.  
  190. ///
  191. /// The constructor from IDataReader.
  192. ///
  193. ///
  194. An initalized IDataReader. internal AspnetUsers(IDataReader reader)
  195. {
  196. if ((reader["ApplicationId"] != null) && (reader["ApplicationId"] != DBNull.Value))
  197. this.applicationid = (Guid)reader["ApplicationId"];
  198. if ((reader["UserId"] != null) && (reader["UserId"] != DBNull.Value))
  199. this.userid = (Guid)reader["UserId"];
  200. if ((reader["UserName"] != null) && (reader["UserName"] != DBNull.Value))
  201. this.username = (string)reader["UserName"];
  202. if ((reader["LoweredUserName"] != null) && (reader["LoweredUserName"] != DBNull.Value))
  203. this.loweredusername = (string)reader["LoweredUserName"];
  204. if ((reader["MobileAlias"] != null) && (reader["MobileAlias"] != DBNull.Value))
  205. this.mobilealias = (string)reader["MobileAlias"];
  206. if ((reader["IsAnonymous"] != null) && (reader["IsAnonymous"] != DBNull.Value))
  207. this.isanonymous = (bool)reader["IsAnonymous"];
  208. if ((reader["LastActivityDate"] != null) && (reader["LastActivityDate"] != DBNull.Value))
  209. this.lastactivitydate = (DateTime)reader["LastActivityDate"];
  210.  
  211. this.isNew = false;
  212. }
  213.  
  214. ///
  215. /// Creates an IDbCommand to insert an object into the database.
  216. ///
  217. /// An initialized IDbCommand object.
  218. internal virtual IDbCommand CreateInsertCommand()
  219. {
  220. SqlCommand cmd = new SqlCommand();
  221. cmd.CommandText = "insert into [dbo].[aspnet_Users] ([ApplicationId], [UserId], [UserName], [LoweredUserName], [MobileAlias], [IsAnonymous], [LastActivityDate]) values (@applicationid, @userid, @username, @loweredusername, @mobilealias, @isanonymous, @lastactivitydate)";
  222. cmd.Parameters.AddWithValue("@applicationid", this.applicationid);
  223. cmd.Parameters.AddWithValue("@userid", this.userid);
  224. cmd.Parameters.AddWithValue("@username", this.username);
  225. cmd.Parameters.AddWithValue("@loweredusername", this.loweredusername);
  226. if (String.IsNullOrEmpty(this.mobilealias))
  227. cmd.Parameters.AddWithValue("@mobilealias", DBNull.Value);
  228. else
  229. cmd.Parameters.AddWithValue("@mobilealias", this.mobilealias);
  230. cmd.Parameters.AddWithValue("@isanonymous", this.isanonymous);
  231. cmd.Parameters.AddWithValue("@lastactivitydate", this.lastactivitydate);
  232.  
  233. cmd.Connection = PersistenceManager.Connection;
  234. return cmd;
  235. }
  236.  
  237. ///
  238. /// Creates an IDbCommand to update an object in the database.
  239. ///
  240. /// An initialized IDbCommand object.
  241. internal virtual IDbCommand CreateUpdateCommand()
  242. {
  243. SqlCommand cmd = new SqlCommand();
  244. cmd.CommandText = "update [dbo].[aspnet_Users] set [ApplicationId]=@applicationid, [UserName]=@username, [LoweredUserName]=@loweredusername, [MobileAlias]=@mobilealias, [IsAnonymous]=@isanonymous, [LastActivityDate]=@lastactivitydate where ([UserId]=@userid)";
  245. cmd.Parameters.AddWithValue("@applicationid", this.applicationid);
  246. cmd.Parameters.AddWithValue("@username", this.username);
  247. cmd.Parameters.AddWithValue("@loweredusername", this.loweredusername);
  248. if (String.IsNullOrEmpty(this.mobilealias))
  249. cmd.Parameters.AddWithValue("@mobilealias", DBNull.Value);
  250. else
  251. cmd.Parameters.AddWithValue("@mobilealias", this.mobilealias);
  252. cmd.Parameters.AddWithValue("@isanonymous", this.isanonymous);
  253. cmd.Parameters.AddWithValue("@lastactivitydate", this.lastactivitydate);
  254. cmd.Parameters.AddWithValue("@userid", this.userid);
  255.  
  256. cmd.Connection = PersistenceManager.Connection;
  257. return cmd;
  258. }
  259.  
  260. ///
  261. /// Creates an IDbCommand to delete an object in the database.
  262. ///
  263. /// An initialized IDbCommand object.
  264. internal virtual IDbCommand CreateDeleteCommand()
  265. {
  266. SqlCommand cmd = new SqlCommand();
  267. cmd.CommandText = "delete from [dbo].[aspnet_Users] where ([UserId]=@userid)";
  268. cmd.Parameters.AddWithValue("@userid", this.userid);
  269.  
  270. cmd.Connection = PersistenceManager.Connection;
  271. return cmd;
  272. }
  273.  
  274. ///
  275. /// Persists the object.
  276. ///
  277. public virtual void Persist()
  278. {
  279. PersistenceManager.InvokeInstanceMethod(this, "PrePersist", null);
  280.  
  281. IDbCommand cmd;
  282.  
  283. if (this.isNew)
  284. cmd = this.CreateInsertCommand();
  285. else
  286. cmd = this.CreateUpdateCommand();
  287.  
  288. cmd.Transaction = PersistenceManager.Transaction;
  289. PersistenceManager.RegisterInTransaction(this);
  290.  
  291. bool connWasClosed =
  292. PersistenceManager.Connection.State.Equals(ConnectionState.Closed) ||
  293. PersistenceManager.Connection.State.Equals(ConnectionState.Broken);
  294.  
  295. try
  296. {
  297. if (connWasClosed)
  298. PersistenceManager.Connection.Open();
  299.  
  300. cmd.ExecuteNonQuery();
  301.  
  302. this.isNew = false;
  303.  
  304. if (connWasClosed)
  305. PersistenceManager.Connection.Close();
  306. }
  307. catch (Exception ex)
  308. {
  309. if (connWasClosed)
  310. PersistenceManager.Connection.Close();
  311. throw ex;
  312. }
  313. }
  314.  
  315. ///
  316. /// Deletes the object.
  317. ///
  318. public virtual void Delete()
  319. {
  320. PersistenceManager.InvokeInstanceMethod(this, "PreDelete", null);
  321.  
  322. IDbCommand cmd = this.CreateDeleteCommand();
  323. cmd.Transaction = PersistenceManager.Transaction;
  324.  
  325. bool connWasClosed =
  326. PersistenceManager.Connection.State.Equals(ConnectionState.Closed) ||
  327. PersistenceManager.Connection.State.Equals(ConnectionState.Broken);
  328.  
  329. try
  330. {
  331. if (connWasClosed)
  332. PersistenceManager.Connection.Open();
  333.  
  334. cmd.ExecuteNonQuery();
  335.  
  336. if (connWasClosed)
  337. PersistenceManager.Connection.Close();
  338. }
  339. catch (Exception ex)
  340. {
  341. if (connWasClosed)
  342. PersistenceManager.Connection.Close();
  343. throw ex;
  344. }
  345. }
  346.  
  347. ///
  348. /// Retrieves a AspnetUsers object by its primary key (Throws System.DataException).
  349. ///
  350. ///
  351. The Userid. /// The AspnetUsers object.
  352. public static AspnetUsers Get(Guid userid)
  353. {
  354. AspnetUsers aspnetusers;
  355. if (AspnetUsers.TryGet(userid, out aspnetusers))
  356. return aspnetusers;
  357. else
  358. throw new DataException("'AspnetUsers' object not found.");
  359. }
  360.  
  361. ///
  362. /// Tries to retrieve a AspnetUsers object by its primary key.
  363. ///
  364. ///
  365. The Userid. ///
  366. The found AspnetUsers or null if the primary key value does not exist. /// True if the AspnetUsers exists, else false.
  367. public static bool TryGet(Guid userid, out AspnetUsers aspnetusers)
  368. {
  369. SqlCommand cmd = new SqlCommand("select * from [dbo].[aspnet_Users] where ([UserId]=@userid)");
  370. cmd.Parameters.AddWithValue("@userid", userid);
  371.  
  372. IList list = AspnetUsers.Query(cmd);
  373.  
  374. if (list.Count == 0)
  375. {
  376. aspnetusers = null;
  377. return false;
  378. }
  379. else
  380. {
  381. aspnetusers = list[0];
  382. return true;
  383. }
  384. }
  385.  
  386. ///
  387. /// For internal use only.
  388. ///
  389. public virtual void SaveState()
  390. {
  391. this._isNew = this.isNew;
  392. }
  393.  
  394. ///
  395. /// For internal use only.
  396. ///
  397. public virtual void RestoreState()
  398. {
  399. this.isNew = this._isNew;
  400. }
  401.  
  402. ///
  403. /// Refreshes the internal state of the object.
  404. ///
  405. /// This method should be called after xml deserialization to refresh internal flags.
  406. public virtual void RefreshState()
  407. {
  408. AspnetUsers aspnetusers;
  409.  
  410. if (AspnetUsers.TryGet(this.userid, out aspnetusers))
  411. {
  412. this.isNew = false;
  413. }
  414. else
  415. {
  416. this.isNew = true;
  417. }
  418. }
  419.  
  420. ///
  421. /// Returns a Data Transfer Object of this AspnetUsers.
  422. ///
  423. /// A Data Transfer Object of this AspnetUsers.
  424. public virtual AspnetUsersDTO GetDTO()
  425. {
  426. AspnetUsersDTO dto = new AspnetUsersDTO();
  427.  
  428. dto.Applicationid = this.Applicationid;
  429. dto.Userid = this.Userid;
  430. dto.Username = this.Username;
  431. dto.Loweredusername = this.Loweredusername;
  432. dto.Mobilealias = this.Mobilealias;
  433. dto.Isanonymous = this.Isanonymous;
  434. dto.Lastactivitydate = this.Lastactivitydate;
  435.  
  436. return dto;
  437. }
  438.  
  439. ///
  440. /// Applies a Data Transfer Object data to this AspnetUsers.
  441. ///
  442. ///
  443. The Data Transfer Object. public virtual void SetDTO(AspnetUsersDTO dto)
  444. {
  445. this.Applicationid = dto.Applicationid;
  446. this.Userid = dto.Userid;
  447. this.Username = dto.Username;
  448. this.Loweredusername = dto.Loweredusername;
  449. this.Mobilealias = dto.Mobilealias;
  450. this.Isanonymous = dto.Isanonymous;
  451. this.Lastactivitydate = dto.Lastactivitydate;
  452. }
  453.  
  454. ///
  455. /// Perfoms a query on AspnetUsers objects.
  456. ///
  457. ///
  458. An IDbCommand containing the select statement. /// A result list of AspnetUsers objects.
  459. internal static IList Query(IDbCommand command)
  460. {
  461. command.Connection = PersistenceManager.Connection;
  462. command.Transaction = PersistenceManager.Transaction;
  463.  
  464. bool connWasClosed =
  465. PersistenceManager.Connection.State.Equals(ConnectionState.Closed) ||
  466. PersistenceManager.Connection.State.Equals(ConnectionState.Broken);
  467.  
  468. try
  469. {
  470. if (connWasClosed)
  471. PersistenceManager.Connection.Open();
  472.  
  473. List list = new List();
  474. IDataReader reader = command.ExecuteReader();
  475.  
  476. using (reader)
  477. {
  478. while (reader.Read())
  479. list.Add(new AspnetUsers(reader));
  480. }
  481.  
  482. if (connWasClosed)
  483. PersistenceManager.Connection.Close();
  484.  
  485. return list;
  486. }
  487. catch (Exception ex)
  488. {
  489. if (connWasClosed)
  490. PersistenceManager.Connection.Close();
  491. throw ex;
  492. }
  493. }
  494.  
  495. ///
  496. /// Finds all AspnetUsers objects with a certain Applicationid value.
  497. ///
  498. ///
  499. The Applicationid value. /// All AspnetUsers objects with a certain Applicationid value.
  500. public static IList FindByApplicationid(Guid applicationid)
  501. {
  502. return AspnetUsers.Query(AspnetUsersCommands.FindByApplicationid(applicationid));
  503. }
  504.  
  505. ///
  506. /// Finds all AspnetUsers objects with a certain Username value.
  507. ///
  508. ///
  509. The Username value ('*' can be used as a wildcard). /// All AspnetUsers objects with a certain Username value.
  510. public static IList FindByUsername(string username)
  511. {
  512. return AspnetUsers.Query(AspnetUsersCommands.FindByUsername(username));
  513. }
  514.  
  515. ///
  516. /// Finds all AspnetUsers objects with a certain Loweredusername value.
  517. ///
  518. ///
  519. The Loweredusername value ('*' can be used as a wildcard). /// All AspnetUsers objects with a certain Loweredusername value.
  520. public static IList FindByLoweredusername(string loweredusername)
  521. {
  522. return AspnetUsers.Query(AspnetUsersCommands.FindByLoweredusername(loweredusername));
  523. }
  524.  
  525. ///
  526. /// Finds all AspnetUsers objects with a certain Mobilealias value.
  527. ///
  528. ///
  529. The Mobilealias value ('*' can be used as a wildcard). /// All AspnetUsers objects with a certain Mobilealias value.
  530. public static IList FindByMobilealias(string mobilealias)
  531. {
  532. return AspnetUsers.Query(AspnetUsersCommands.FindByMobilealias(mobilealias));
  533. }
  534.  
  535. ///
  536. /// Finds all AspnetUsers objects with a certain Isanonymous value.
  537. ///
  538. ///
  539. The Isanonymous value. /// All AspnetUsers objects with a certain Isanonymous value.
  540. public static IList FindByIsanonymous(bool isanonymous)
  541. {
  542. return AspnetUsers.Query(AspnetUsersCommands.FindByIsanonymous(isanonymous));
  543. }
  544.  
  545. ///
  546. /// Finds all AspnetUsers objects with a certain Lastactivitydate value.
  547. ///
  548. ///
  549. The Lastactivitydate value. /// All AspnetUsers objects with a certain Lastactivitydate value.
  550. public static IList FindByLastactivitydate(DateTime lastactivitydate)
  551. {
  552. return AspnetUsers.Query(AspnetUsersCommands.FindByLastactivitydate(lastactivitydate));
  553. }
  554.  
  555. }
  556. }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>