AspnetMembership Partial Class

This is the base partial data object class for the “membership” table in the provider database. Using this class implies that there will be a singular relationship between the remaining provider tables and relevant data objects.
[csharp]
//*****************************************************************************
// This file is part of the data access layer example to the ASP.NET 2.0 provider database
// This file was written by Adam Buenz [WSS MVP] of ARB Security Solutions, LLC
// http://www.sharepointsecurity.com
//
// This file and its parts is free for re-distribution, for use in both free
// and commercial applications, however this header must remain intact for legal
// use. The data access layer example is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//*****************************************************************************
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Aspnet.Provider.Datalayer.Commands;
using Aspnet.Provider.Datalayer.DataTransferObjects;

namespace Aspnet.Provider.Datalayer
{
///

/// The AspnetMembership class.
///

public partial class AspnetMembership : IPersistable
{
#region Members

private bool isNew;
private bool _isNew;
private Guid applicationid;
private Guid userid;
private string password;
private int passwordformat;
private string passwordsalt;
private string mobilepin;
private string email;
private string loweredemail;
private string passwordquestion;
private string passwordanswer;
private bool isapproved;
private bool islockedout;
private DateTime createdate;
private DateTime lastlogindate;
private DateTime lastpasswordchangeddate;
private DateTime lastlockoutdate;
private int failedpasswordattemptcount;
private DateTime failedpasswordattemptwindowstart;
private int failedpasswordanswerattemptcount;
private DateTime failedpasswordanswerattemptwindowstart;
private string comment;

#endregion

#region Properties

///

/// The Applicationid.
///

public virtual Guid Applicationid
{
get { return this.applicationid; }
set { this.applicationid = value; }
}

///

/// The Userid.
///

public virtual Guid Userid
{
get { return this.userid; }
set { this.userid = value; }
}

///

/// The Password.
///

[StringInfo(128, true)]
public virtual string Password
{
get { return this.password; }
set { this.password = value; }
}

///

/// The Passwordformat.
///

public virtual int Passwordformat
{
get { return this.passwordformat; }
set { this.passwordformat = value; }
}

///

/// The Passwordsalt.
///

[StringInfo(128, true)]
public virtual string Passwordsalt
{
get { return this.passwordsalt; }
set { this.passwordsalt = value; }
}

///

/// The Mobilepin.
///

[StringInfo(16, false)]
public virtual string Mobilepin
{
get { return this.mobilepin; }
set { this.mobilepin = value; }
}

///

/// The Email.
///

[StringInfo(256, false)]
public virtual string Email
{
get { return this.email; }
set { this.email = value; }
}

///

/// The Loweredemail.
///

[StringInfo(256, false)]
public virtual string Loweredemail
{
get { return this.loweredemail; }
set { this.loweredemail = value; }
}

///

/// The Passwordquestion.
///

[StringInfo(256, false)]
public virtual string Passwordquestion
{
get { return this.passwordquestion; }
set { this.passwordquestion = value; }
}

///

/// The Passwordanswer.
///

[StringInfo(128, false)]
public virtual string Passwordanswer
{
get { return this.passwordanswer; }
set { this.passwordanswer = value; }
}

///

/// The Isapproved.
///

public virtual bool Isapproved
{
get { return this.isapproved; }
set { this.isapproved = value; }
}

///

/// The Islockedout.
///

public virtual bool Islockedout
{
get { return this.islockedout; }
set { this.islockedout = value; }
}

///

/// The Createdate.
///

public virtual DateTime Createdate
{
get { return this.createdate; }
set { this.createdate = value; }
}

///

/// The Lastlogindate.
///

public virtual DateTime Lastlogindate
{
get { return this.lastlogindate; }
set { this.lastlogindate = value; }
}

///

/// The Lastpasswordchangeddate.
///

public virtual DateTime Lastpasswordchangeddate
{
get { return this.lastpasswordchangeddate; }
set { this.lastpasswordchangeddate = value; }
}

///

/// The Lastlockoutdate.
///

public virtual DateTime Lastlockoutdate
{
get { return this.lastlockoutdate; }
set { this.lastlockoutdate = value; }
}

///

/// The Failedpasswordattemptcount.
///

public virtual int Failedpasswordattemptcount
{
get { return this.failedpasswordattemptcount; }
set { this.failedpasswordattemptcount = value; }
}

///

/// The Failedpasswordattemptwindowstart.
///

public virtual DateTime Failedpasswordattemptwindowstart
{
get { return this.failedpasswordattemptwindowstart; }
set { this.failedpasswordattemptwindowstart = value; }
}

///

/// The Failedpasswordanswerattemptcount.
///

public virtual int Failedpasswordanswerattemptcount
{
get { return this.failedpasswordanswerattemptcount; }
set { this.failedpasswordanswerattemptcount = value; }
}

///

/// The Failedpasswordanswerattemptwindowstart.
///

public virtual DateTime Failedpasswordanswerattemptwindowstart
{
get { return this.failedpasswordanswerattemptwindowstart; }
set { this.failedpasswordanswerattemptwindowstart = value; }
}

///

/// The Comment.
///

public virtual string Comment
{
get { return this.comment; }
set { this.comment = value; }
}

#endregion

#region ColumnNames

///

/// The corresponding schema name.
///

internal const string SchemaName = “dbo”;

///

/// The corresponding table name.
///

internal const string TableName = “aspnet_Membership”;

///

/// The column names.
///

internal class ColumnNames
{
///

/// The column name of the Applicationid property.
///

public const string Applicationid=”ApplicationId”;
///

/// The column name of the Userid property.
///

public const string Userid=”UserId”;
///

/// The column name of the Password property.
///

public const string Password=”Password”;
///

/// The column name of the Passwordformat property.
///

public const string Passwordformat=”PasswordFormat”;
///

/// The column name of the Passwordsalt property.
///

public const string Passwordsalt=”PasswordSalt”;
///

/// The column name of the Mobilepin property.
///

public const string Mobilepin=”MobilePIN”;
///

/// The column name of the Email property.
///

public const string Email=”Email”;
///

/// The column name of the Loweredemail property.
///

public const string Loweredemail=”LoweredEmail”;
///

/// The column name of the Passwordquestion property.
///

public const string Passwordquestion=”PasswordQuestion”;
///

/// The column name of the Passwordanswer property.
///

public const string Passwordanswer=”PasswordAnswer”;
///

/// The column name of the Isapproved property.
///

public const string Isapproved=”IsApproved”;
///

/// The column name of the Islockedout property.
///

public const string Islockedout=”IsLockedOut”;
///

/// The column name of the Createdate property.
///

public const string Createdate=”CreateDate”;
///

/// The column name of the Lastlogindate property.
///

public const string Lastlogindate=”LastLoginDate”;
///

/// The column name of the Lastpasswordchangeddate property.
///

public const string Lastpasswordchangeddate=”LastPasswordChangedDate”;
///

/// The column name of the Lastlockoutdate property.
///

public const string Lastlockoutdate=”LastLockoutDate”;
///

/// The column name of the Failedpasswordattemptcount property.
///

public const string Failedpasswordattemptcount=”FailedPasswordAttemptCount”;
///

/// The column name of the Failedpasswordattemptwindowstart property.
///

public const string Failedpasswordattemptwindowstart=”FailedPasswordAttemptWindowStart”;
///

/// The column name of the Failedpasswordanswerattemptcount property.
///

public const string Failedpasswordanswerattemptcount=”FailedPasswordAnswerAttemptCount”;
///

/// The column name of the Failedpasswordanswerattemptwindowstart property.
///

public const string Failedpasswordanswerattemptwindowstart=”FailedPasswordAnswerAttemptWindowStart”;
///

/// The column name of the Comment property.
///

public const string Comment=”Comment”;
}

#endregion

///

/// The default constructor.
///

public AspnetMembership()
{
this.isNew = true;
PersistenceManager.InvokeInstanceMethod(this, “CreationComplete”, null);
}

///

/// The constructor of the required fields.
///

/// The Applicationid. /// The Userid. /// The Password. /// The Passwordformat. /// The Passwordsalt. /// The Isapproved. /// The Islockedout. /// The Createdate. /// The Lastlogindate. /// The Lastpasswordchangeddate. /// The Lastlockoutdate. /// The Failedpasswordattemptcount. /// The Failedpasswordattemptwindowstart. /// The Failedpasswordanswerattemptcount. /// The Failedpasswordanswerattemptwindowstart. public AspnetMembership(Guid applicationid, Guid userid, string password, int passwordformat, string passwordsalt, bool isapproved, bool islockedout, DateTime createdate, DateTime lastlogindate, DateTime lastpasswordchangeddate, DateTime lastlockoutdate, int failedpasswordattemptcount, DateTime failedpasswordattemptwindowstart, int failedpasswordanswerattemptcount, DateTime failedpasswordanswerattemptwindowstart)
{
this.applicationid = applicationid;
this.userid = userid;
this.password = password;
this.passwordformat = passwordformat;
this.passwordsalt = passwordsalt;
this.isapproved = isapproved;
this.islockedout = islockedout;
this.createdate = createdate;
this.lastlogindate = lastlogindate;
this.lastpasswordchangeddate = lastpasswordchangeddate;
this.lastlockoutdate = lastlockoutdate;
this.failedpasswordattemptcount = failedpasswordattemptcount;
this.failedpasswordattemptwindowstart = failedpasswordattemptwindowstart;
this.failedpasswordanswerattemptcount = failedpasswordanswerattemptcount;
this.failedpasswordanswerattemptwindowstart = failedpasswordanswerattemptwindowstart;

this.isNew = true;
PersistenceManager.InvokeInstanceMethod(this, “CreationComplete”, null);
}

///

/// The constructor from IDataReader.
///

/// An initalized IDataReader. internal AspnetMembership(IDataReader reader)
{
if ((reader[“ApplicationId”] != null) && (reader[“ApplicationId”] != DBNull.Value))
this.applicationid = (Guid)reader[“ApplicationId”];
if ((reader[“UserId”] != null) && (reader[“UserId”] != DBNull.Value))
this.userid = (Guid)reader[“UserId”];
if ((reader[“Password”] != null) && (reader[“Password”] != DBNull.Value))
this.password = (string)reader[“Password”];
if ((reader[“PasswordFormat”] != null) && (reader[“PasswordFormat”] != DBNull.Value))
this.passwordformat = (int)reader[“PasswordFormat”];
if ((reader[“PasswordSalt”] != null) && (reader[“PasswordSalt”] != DBNull.Value))
this.passwordsalt = (string)reader[“PasswordSalt”];
if ((reader[“MobilePIN”] != null) && (reader[“MobilePIN”] != DBNull.Value))
this.mobilepin = (string)reader[“MobilePIN”];
if ((reader[“Email”] != null) && (reader[“Email”] != DBNull.Value))
this.email = (string)reader[“Email”];
if ((reader[“LoweredEmail”] != null) && (reader[“LoweredEmail”] != DBNull.Value))
this.loweredemail = (string)reader[“LoweredEmail”];
if ((reader[“PasswordQuestion”] != null) && (reader[“PasswordQuestion”] != DBNull.Value))
this.passwordquestion = (string)reader[“PasswordQuestion”];
if ((reader[“PasswordAnswer”] != null) && (reader[“PasswordAnswer”] != DBNull.Value))
this.passwordanswer = (string)reader[“PasswordAnswer”];
if ((reader[“IsApproved”] != null) && (reader[“IsApproved”] != DBNull.Value))
this.isapproved = (bool)reader[“IsApproved”];
if ((reader[“IsLockedOut”] != null) && (reader[“IsLockedOut”] != DBNull.Value))
this.islockedout = (bool)reader[“IsLockedOut”];
if ((reader[“CreateDate”] != null) && (reader[“CreateDate”] != DBNull.Value))
this.createdate = (DateTime)reader[“CreateDate”];
if ((reader[“LastLoginDate”] != null) && (reader[“LastLoginDate”] != DBNull.Value))
this.lastlogindate = (DateTime)reader[“LastLoginDate”];
if ((reader[“LastPasswordChangedDate”] != null) && (reader[“LastPasswordChangedDate”] != DBNull.Value))
this.lastpasswordchangeddate = (DateTime)reader[“LastPasswordChangedDate”];
if ((reader[“LastLockoutDate”] != null) && (reader[“LastLockoutDate”] != DBNull.Value))
this.lastlockoutdate = (DateTime)reader[“LastLockoutDate”];
if ((reader[“FailedPasswordAttemptCount”] != null) && (reader[“FailedPasswordAttemptCount”] != DBNull.Value))
this.failedpasswordattemptcount = (int)reader[“FailedPasswordAttemptCount”];
if ((reader[“FailedPasswordAttemptWindowStart”] != null) && (reader[“FailedPasswordAttemptWindowStart”] != DBNull.Value))
this.failedpasswordattemptwindowstart = (DateTime)reader[“FailedPasswordAttemptWindowStart”];
if ((reader[“FailedPasswordAnswerAttemptCount”] != null) && (reader[“FailedPasswordAnswerAttemptCount”] != DBNull.Value))
this.failedpasswordanswerattemptcount = (int)reader[“FailedPasswordAnswerAttemptCount”];
if ((reader[“FailedPasswordAnswerAttemptWindowStart”] != null) && (reader[“FailedPasswordAnswerAttemptWindowStart”] != DBNull.Value))
this.failedpasswordanswerattemptwindowstart = (DateTime)reader[“FailedPasswordAnswerAttemptWindowStart”];
if ((reader[“Comment”] != null) && (reader[“Comment”] != DBNull.Value))
this.comment = (string)reader[“Comment”];

this.isNew = false;
}

///

/// Creates an IDbCommand to insert an object into the database.
///

/// An initialized IDbCommand object.
internal virtual IDbCommand CreateInsertCommand()
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = “insert into [dbo].[aspnet_Membership] ([ApplicationId], [UserId], [Password], [PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail], [PasswordQuestion], [PasswordAnswer], [IsApproved], [IsLockedOut], [CreateDate], [LastLoginDate], [LastPasswordChangedDate], [LastLockoutDate], [FailedPasswordAttemptCount], [FailedPasswordAttemptWindowStart], [FailedPasswordAnswerAttemptCount], [FailedPasswordAnswerAttemptWindowStart], [Comment]) values (@applicationid, @userid, @password, @passwordformat, @passwordsalt, @mobilepin, @email, @loweredemail, @passwordquestion, @passwordanswer, @isapproved, @islockedout, @createdate, @lastlogindate, @lastpasswordchangeddate, @lastlockoutdate, @failedpasswordattemptcount, @failedpasswordattemptwindowstart, @failedpasswordanswerattemptcount, @failedpasswordanswerattemptwindowstart, @comment)”;
cmd.Parameters.AddWithValue(“@applicationid”, this.applicationid);
cmd.Parameters.AddWithValue(“@userid”, this.userid);
cmd.Parameters.AddWithValue(“@password”, this.password);
cmd.Parameters.AddWithValue(“@passwordformat”, this.passwordformat);
cmd.Parameters.AddWithValue(“@passwordsalt”, this.passwordsalt);
if (String.IsNullOrEmpty(this.mobilepin))
cmd.Parameters.AddWithValue(“@mobilepin”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@mobilepin”, this.mobilepin);
if (String.IsNullOrEmpty(this.email))
cmd.Parameters.AddWithValue(“@email”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@email”, this.email);
if (String.IsNullOrEmpty(this.loweredemail))
cmd.Parameters.AddWithValue(“@loweredemail”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@loweredemail”, this.loweredemail);
if (String.IsNullOrEmpty(this.passwordquestion))
cmd.Parameters.AddWithValue(“@passwordquestion”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@passwordquestion”, this.passwordquestion);
if (String.IsNullOrEmpty(this.passwordanswer))
cmd.Parameters.AddWithValue(“@passwordanswer”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@passwordanswer”, this.passwordanswer);
cmd.Parameters.AddWithValue(“@isapproved”, this.isapproved);
cmd.Parameters.AddWithValue(“@islockedout”, this.islockedout);
cmd.Parameters.AddWithValue(“@createdate”, this.createdate);
cmd.Parameters.AddWithValue(“@lastlogindate”, this.lastlogindate);
cmd.Parameters.AddWithValue(“@lastpasswordchangeddate”, this.lastpasswordchangeddate);
cmd.Parameters.AddWithValue(“@lastlockoutdate”, this.lastlockoutdate);
cmd.Parameters.AddWithValue(“@failedpasswordattemptcount”, this.failedpasswordattemptcount);
cmd.Parameters.AddWithValue(“@failedpasswordattemptwindowstart”, this.failedpasswordattemptwindowstart);
cmd.Parameters.AddWithValue(“@failedpasswordanswerattemptcount”, this.failedpasswordanswerattemptcount);
cmd.Parameters.AddWithValue(“@failedpasswordanswerattemptwindowstart”, this.failedpasswordanswerattemptwindowstart);
if (String.IsNullOrEmpty(this.comment))
cmd.Parameters.AddWithValue(“@comment”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@comment”, this.comment);

cmd.Connection = PersistenceManager.Connection;
return cmd;
}

///

/// Creates an IDbCommand to update an object in the database.
///

/// An initialized IDbCommand object.
internal virtual IDbCommand CreateUpdateCommand()
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = “update [dbo].[aspnet_Membership] set [ApplicationId]=@applicationid, [Password]=@password, [PasswordFormat]=@passwordformat, [PasswordSalt]=@passwordsalt, [MobilePIN]=@mobilepin, [Email]=@email, [LoweredEmail]=@loweredemail, [PasswordQuestion]=@passwordquestion, [PasswordAnswer]=@passwordanswer, [IsApproved]=@isapproved, [IsLockedOut]=@islockedout, [CreateDate]=@createdate, [LastLoginDate]=@lastlogindate, [LastPasswordChangedDate]=@lastpasswordchangeddate, [LastLockoutDate]=@lastlockoutdate, [FailedPasswordAttemptCount]=@failedpasswordattemptcount, [FailedPasswordAttemptWindowStart]=@failedpasswordattemptwindowstart, [FailedPasswordAnswerAttemptCount]=@failedpasswordanswerattemptcount, [FailedPasswordAnswerAttemptWindowStart]=@failedpasswordanswerattemptwindowstart, [Comment]=@comment where ([UserId]=@userid)”;
cmd.Parameters.AddWithValue(“@applicationid”, this.applicationid);
cmd.Parameters.AddWithValue(“@password”, this.password);
cmd.Parameters.AddWithValue(“@passwordformat”, this.passwordformat);
cmd.Parameters.AddWithValue(“@passwordsalt”, this.passwordsalt);
if (String.IsNullOrEmpty(this.mobilepin))
cmd.Parameters.AddWithValue(“@mobilepin”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@mobilepin”, this.mobilepin);
if (String.IsNullOrEmpty(this.email))
cmd.Parameters.AddWithValue(“@email”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@email”, this.email);
if (String.IsNullOrEmpty(this.loweredemail))
cmd.Parameters.AddWithValue(“@loweredemail”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@loweredemail”, this.loweredemail);
if (String.IsNullOrEmpty(this.passwordquestion))
cmd.Parameters.AddWithValue(“@passwordquestion”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@passwordquestion”, this.passwordquestion);
if (String.IsNullOrEmpty(this.passwordanswer))
cmd.Parameters.AddWithValue(“@passwordanswer”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@passwordanswer”, this.passwordanswer);
cmd.Parameters.AddWithValue(“@isapproved”, this.isapproved);
cmd.Parameters.AddWithValue(“@islockedout”, this.islockedout);
cmd.Parameters.AddWithValue(“@createdate”, this.createdate);
cmd.Parameters.AddWithValue(“@lastlogindate”, this.lastlogindate);
cmd.Parameters.AddWithValue(“@lastpasswordchangeddate”, this.lastpasswordchangeddate);
cmd.Parameters.AddWithValue(“@lastlockoutdate”, this.lastlockoutdate);
cmd.Parameters.AddWithValue(“@failedpasswordattemptcount”, this.failedpasswordattemptcount);
cmd.Parameters.AddWithValue(“@failedpasswordattemptwindowstart”, this.failedpasswordattemptwindowstart);
cmd.Parameters.AddWithValue(“@failedpasswordanswerattemptcount”, this.failedpasswordanswerattemptcount);
cmd.Parameters.AddWithValue(“@failedpasswordanswerattemptwindowstart”, this.failedpasswordanswerattemptwindowstart);
if (String.IsNullOrEmpty(this.comment))
cmd.Parameters.AddWithValue(“@comment”, DBNull.Value);
else
cmd.Parameters.AddWithValue(“@comment”, this.comment);
cmd.Parameters.AddWithValue(“@userid”, this.userid);

cmd.Connection = PersistenceManager.Connection;
return cmd;
}

///

/// Creates an IDbCommand to delete an object in the database.
///

/// An initialized IDbCommand object.
internal virtual IDbCommand CreateDeleteCommand()
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = “delete from [dbo].[aspnet_Membership] where ([UserId]=@userid)”;
cmd.Parameters.AddWithValue(“@userid”, this.userid);

cmd.Connection = PersistenceManager.Connection;
return cmd;
}

///

/// Persists the object.
///

public virtual void Persist()
{
PersistenceManager.InvokeInstanceMethod(this, “PrePersist”, null);

IDbCommand cmd;

if (this.isNew)
cmd = this.CreateInsertCommand();
else
cmd = this.CreateUpdateCommand();

cmd.Transaction = PersistenceManager.Transaction;
PersistenceManager.RegisterInTransaction(this);

bool connWasClosed =
PersistenceManager.Connection.State.Equals(ConnectionState.Closed) ||
PersistenceManager.Connection.State.Equals(ConnectionState.Broken);

try
{
if (connWasClosed)
PersistenceManager.Connection.Open();

cmd.ExecuteNonQuery();

this.isNew = false;

if (connWasClosed)
PersistenceManager.Connection.Close();
}
catch (Exception ex)
{
if (connWasClosed)
PersistenceManager.Connection.Close();
throw ex;
}
}

///

/// Deletes the object.
///

public virtual void Delete()
{
PersistenceManager.InvokeInstanceMethod(this, “PreDelete”, null);

IDbCommand cmd = this.CreateDeleteCommand();
cmd.Transaction = PersistenceManager.Transaction;

bool connWasClosed =
PersistenceManager.Connection.State.Equals(ConnectionState.Closed) ||
PersistenceManager.Connection.State.Equals(ConnectionState.Broken);

try
{
if (connWasClosed)
PersistenceManager.Connection.Open();

cmd.ExecuteNonQuery();

if (connWasClosed)
PersistenceManager.Connection.Close();
}
catch (Exception ex)
{
if (connWasClosed)
PersistenceManager.Connection.Close();
throw ex;
}
}

///

/// Retrieves a AspnetMembership object by its primary key (Throws System.DataException).
///

/// The Userid. /// The AspnetMembership object.
public static AspnetMembership Get(Guid userid)
{
AspnetMembership aspnetmembership;
if (AspnetMembership.TryGet(userid, out aspnetmembership))
return aspnetmembership;
else
throw new DataException(“‘AspnetMembership’ object not found.”);
}

///

/// Tries to retrieve a AspnetMembership object by its primary key.
///

/// The Userid. /// The found AspnetMembership or null if the primary key value does not exist. /// True if the AspnetMembership exists, else false.
public static bool TryGet(Guid userid, out AspnetMembership aspnetmembership)
{
SqlCommand cmd = new SqlCommand(“select * from [dbo].[aspnet_Membership] where ([UserId]=@userid)”);
cmd.Parameters.AddWithValue(“@userid”, userid);

IList list = AspnetMembership.Query(cmd);

if (list.Count == 0)
{
aspnetmembership = null;
return false;
}
else
{
aspnetmembership = list[0];
return true;
}
}

///

/// For internal use only.
///

public virtual void SaveState()
{
this._isNew = this.isNew;
}

///

/// For internal use only.
///

public virtual void RestoreState()
{
this.isNew = this._isNew;
}

///

/// Refreshes the internal state of the object.
///

/// This method should be called after xml deserialization to refresh internal flags.
public virtual void RefreshState()
{
AspnetMembership aspnetmembership;

if (AspnetMembership.TryGet(this.userid, out aspnetmembership))
{
this.isNew = false;
}
else
{
this.isNew = true;
}
}

///

/// Returns a Data Transfer Object of this AspnetMembership.
///

/// A Data Transfer Object of this AspnetMembership.
public virtual AspnetMembershipDTO GetDTO()
{
AspnetMembershipDTO dto = new AspnetMembershipDTO();

dto.Applicationid = this.Applicationid;
dto.Userid = this.Userid;
dto.Password = this.Password;
dto.Passwordformat = this.Passwordformat;
dto.Passwordsalt = this.Passwordsalt;
dto.Mobilepin = this.Mobilepin;
dto.Email = this.Email;
dto.Loweredemail = this.Loweredemail;
dto.Passwordquestion = this.Passwordquestion;
dto.Passwordanswer = this.Passwordanswer;
dto.Isapproved = this.Isapproved;
dto.Islockedout = this.Islockedout;
dto.Createdate = this.Createdate;
dto.Lastlogindate = this.Lastlogindate;
dto.Lastpasswordchangeddate = this.Lastpasswordchangeddate;
dto.Lastlockoutdate = this.Lastlockoutdate;
dto.Failedpasswordattemptcount = this.Failedpasswordattemptcount;
dto.Failedpasswordattemptwindowstart = this.Failedpasswordattemptwindowstart;
dto.Failedpasswordanswerattemptcount = this.Failedpasswordanswerattemptcount;
dto.Failedpasswordanswerattemptwindowstart = this.Failedpasswordanswerattemptwindowstart;
dto.Comment = this.Comment;

return dto;
}

///

/// Applies a Data Transfer Object data to this AspnetMembership.
///

/// The Data Transfer Object. public virtual void SetDTO(AspnetMembershipDTO dto)
{
this.Applicationid = dto.Applicationid;
this.Userid = dto.Userid;
this.Password = dto.Password;
this.Passwordformat = dto.Passwordformat;
this.Passwordsalt = dto.Passwordsalt;
this.Mobilepin = dto.Mobilepin;
this.Email = dto.Email;
this.Loweredemail = dto.Loweredemail;
this.Passwordquestion = dto.Passwordquestion;
this.Passwordanswer = dto.Passwordanswer;
this.Isapproved = dto.Isapproved;
this.Islockedout = dto.Islockedout;
this.Createdate = dto.Createdate;
this.Lastlogindate = dto.Lastlogindate;
this.Lastpasswordchangeddate = dto.Lastpasswordchangeddate;
this.Lastlockoutdate = dto.Lastlockoutdate;
this.Failedpasswordattemptcount = dto.Failedpasswordattemptcount;
this.Failedpasswordattemptwindowstart = dto.Failedpasswordattemptwindowstart;
this.Failedpasswordanswerattemptcount = dto.Failedpasswordanswerattemptcount;
this.Failedpasswordanswerattemptwindowstart = dto.Failedpasswordanswerattemptwindowstart;
this.Comment = dto.Comment;
}

///

/// Perfoms a query on AspnetMembership objects.
///

/// An IDbCommand containing the select statement. /// A result list of AspnetMembership objects.
internal static IList Query(IDbCommand command)
{
command.Connection = PersistenceManager.Connection;
command.Transaction = PersistenceManager.Transaction;

bool connWasClosed =
PersistenceManager.Connection.State.Equals(ConnectionState.Closed) ||
PersistenceManager.Connection.State.Equals(ConnectionState.Broken);

try
{
if (connWasClosed)
PersistenceManager.Connection.Open();

List list = new List();
IDataReader reader = command.ExecuteReader();

using (reader)
{
while (reader.Read())
list.Add(new AspnetMembership(reader));
}

if (connWasClosed)
PersistenceManager.Connection.Close();

return list;
}
catch (Exception ex)
{
if (connWasClosed)
PersistenceManager.Connection.Close();
throw ex;
}
}

///

/// Finds all AspnetMembership objects with a certain Applicationid value.
///

/// The Applicationid value. /// All AspnetMembership objects with a certain Applicationid value.
public static IList FindByApplicationid(Guid applicationid)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByApplicationid(applicationid));
}

///

/// Finds all AspnetMembership objects with a certain Password value.
///

/// The Password value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Password value.
public static IList FindByPassword(string password)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByPassword(password));
}

///

/// Finds all AspnetMembership objects with a certain Passwordformat value.
///

/// The Passwordformat value. /// All AspnetMembership objects with a certain Passwordformat value.
public static IList FindByPasswordformat(int passwordformat)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByPasswordformat(passwordformat));
}

///

/// Finds all AspnetMembership objects with a certain Passwordsalt value.
///

/// The Passwordsalt value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Passwordsalt value.
public static IList FindByPasswordsalt(string passwordsalt)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByPasswordsalt(passwordsalt));
}

///

/// Finds all AspnetMembership objects with a certain Mobilepin value.
///

/// The Mobilepin value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Mobilepin value.
public static IList FindByMobilepin(string mobilepin)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByMobilepin(mobilepin));
}

///

/// Finds all AspnetMembership objects with a certain Email value.
///

/// The Email value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Email value.
public static IList FindByEmail(string email)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByEmail(email));
}

///

/// Finds all AspnetMembership objects with a certain Loweredemail value.
///

/// The Loweredemail value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Loweredemail value.
public static IList FindByLoweredemail(string loweredemail)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByLoweredemail(loweredemail));
}

///

/// Finds all AspnetMembership objects with a certain Passwordquestion value.
///

/// The Passwordquestion value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Passwordquestion value.
public static IList FindByPasswordquestion(string passwordquestion)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByPasswordquestion(passwordquestion));
}

///

/// Finds all AspnetMembership objects with a certain Passwordanswer value.
///

/// The Passwordanswer value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Passwordanswer value.
public static IList FindByPasswordanswer(string passwordanswer)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByPasswordanswer(passwordanswer));
}

///

/// Finds all AspnetMembership objects with a certain Isapproved value.
///

/// The Isapproved value. /// All AspnetMembership objects with a certain Isapproved value.
public static IList FindByIsapproved(bool isapproved)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByIsapproved(isapproved));
}

///

/// Finds all AspnetMembership objects with a certain Islockedout value.
///

/// The Islockedout value. /// All AspnetMembership objects with a certain Islockedout value.
public static IList FindByIslockedout(bool islockedout)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByIslockedout(islockedout));
}

///

/// Finds all AspnetMembership objects with a certain Createdate value.
///

/// The Createdate value. /// All AspnetMembership objects with a certain Createdate value.
public static IList FindByCreatedate(DateTime createdate)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByCreatedate(createdate));
}

///

/// Finds all AspnetMembership objects with a certain Lastlogindate value.
///

/// The Lastlogindate value. /// All AspnetMembership objects with a certain Lastlogindate value.
public static IList FindByLastlogindate(DateTime lastlogindate)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByLastlogindate(lastlogindate));
}

///

/// Finds all AspnetMembership objects with a certain Lastpasswordchangeddate value.
///

/// The Lastpasswordchangeddate value. /// All AspnetMembership objects with a certain Lastpasswordchangeddate value.
public static IList FindByLastpasswordchangeddate(DateTime lastpasswordchangeddate)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByLastpasswordchangeddate(lastpasswordchangeddate));
}

///

/// Finds all AspnetMembership objects with a certain Lastlockoutdate value.
///

/// The Lastlockoutdate value. /// All AspnetMembership objects with a certain Lastlockoutdate value.
public static IList FindByLastlockoutdate(DateTime lastlockoutdate)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByLastlockoutdate(lastlockoutdate));
}

///

/// Finds all AspnetMembership objects with a certain Failedpasswordattemptcount value.
///

/// The Failedpasswordattemptcount value. /// All AspnetMembership objects with a certain Failedpasswordattemptcount value.
public static IList FindByFailedpasswordattemptcount(int failedpasswordattemptcount)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByFailedpasswordattemptcount(failedpasswordattemptcount));
}

///

/// Finds all AspnetMembership objects with a certain Failedpasswordattemptwindowstart value.
///

/// The Failedpasswordattemptwindowstart value. /// All AspnetMembership objects with a certain Failedpasswordattemptwindowstart value.
public static IList FindByFailedpasswordattemptwindowstart(DateTime failedpasswordattemptwindowstart)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByFailedpasswordattemptwindowstart(failedpasswordattemptwindowstart));
}

///

/// Finds all AspnetMembership objects with a certain Failedpasswordanswerattemptcount value.
///

/// The Failedpasswordanswerattemptcount value. /// All AspnetMembership objects with a certain Failedpasswordanswerattemptcount value.
public static IList FindByFailedpasswordanswerattemptcount(int failedpasswordanswerattemptcount)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByFailedpasswordanswerattemptcount(failedpasswordanswerattemptcount));
}

///

/// Finds all AspnetMembership objects with a certain Failedpasswordanswerattemptwindowstart value.
///

/// The Failedpasswordanswerattemptwindowstart value. /// All AspnetMembership objects with a certain Failedpasswordanswerattemptwindowstart value.
public static IList FindByFailedpasswordanswerattemptwindowstart(DateTime failedpasswordanswerattemptwindowstart)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByFailedpasswordanswerattemptwindowstart(failedpasswordanswerattemptwindowstart));
}

///

/// Finds all AspnetMembership objects with a certain Comment value.
///

/// The Comment value (‘*’ can be used as a wildcard). /// All AspnetMembership objects with a certain Comment value.
public static IList FindByComment(string comment)
{
return AspnetMembership.Query(AspnetMembershipCommands.FindByComment(comment));
}

}
}
[/csharp]

Share

Leave a Reply

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