context: using System; 
  using System.Data.Linq;
  using System.Data.Linq.Mapping;
  using System.Data;
  using System.Collections.Generic;
  using System.Reflection;
  using System.Linq;
  using System.Linq.Expressions;
  using System.ComponentModel;
  using CmsData.Infrastructure;
  
  namespace CmsData
  {
  	[Table(Name="dbo.Users")]
  	public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
  	{
  		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
  		
  	#region Private Fields
  		
  		private int _UserId;
  		
  		private int? _PeopleId;
  		
  		private string _Username;
  		
  		private string _Comment;
  		
  		private string _Password;
  		
  		private string _PasswordQuestion;
  		
  		private string _PasswordAnswer;
  		
  		private bool _IsApproved;
  		
  		private DateTime? _LastActivityDate;
  		
  		private DateTime? _LastLoginDate;
  		
  		private DateTime? _LastPasswordChangedDate;
  		
  		private DateTime? _CreationDate;
  		
  		private bool _IsLockedOut;
  		
  		private DateTime? _LastLockedOutDate;
  		
  		private int _FailedPasswordAttemptCount;
  		
  		private DateTime? _FailedPasswordAttemptWindowStart;
  		
  		private int _FailedPasswordAnswerAttemptCount;
  		
  		private DateTime? _FailedPasswordAnswerAttemptWindowStart;
  		
  		private string _EmailAddress;
  		
  		private int? _ItemsInGrid;
  		
  		private string _CurrentCart;
  		
  		private bool _MustChangePassword;
  		
  		private string _Host;
  		
  		private string _TempPassword;
  		
  		private string _Name;
  		
  		private string _Name2;
  		
  		private Guid? _ResetPasswordCode;
  		
  		private string _DefaultGroup;
  		
  		private DateTime? _ResetPasswordExpires;
  		
     		
     		private EntitySet< Coupon> _Coupons;
  		
     		private EntitySet< SMSGroupMember> _SMSGroupMembers;
  		
     		private EntitySet< Preference> _Preferences;
  		
     		private EntitySet< UserRole> _UserRoles;
  		
     		private EntitySet< ApiSession> _ApiSessions;
  		
     		private EntitySet< VolunteerForm> _VolunteerFormsUploaded;
  		
      	
  		private EntityRef< Person> _Person;
  		
  	#endregion
  	
      #region Extensibility Method Definitions
      partial void OnLoaded();
      partial void OnValidate(System.Data.Linq.ChangeAction action);
      partial void OnCreated();
  		
  		partial void OnUserIdChanging(int value);
  		partial void OnUserIdChanged();
  		
  		partial void OnPeopleIdChanging(int? value);
  		partial void OnPeopleIdChanged();
  		
  		partial void OnUsernameChanging(string value);
  		partial void OnUsernameChanged();
  		
  		partial void OnCommentChanging(string value);
  		partial void OnCommentChanged();
  		
  		partial void OnPasswordChanging(string value);
  		partial void OnPasswordChanged();
  		
  		partial void OnPasswordQuestionChanging(string value);
  		partial void OnPasswordQuestionChanged();
  		
  		partial void OnPasswordAnswerChanging(string value);
  		partial void OnPasswordAnswerChanged();
  		
  		partial void OnIsApprovedChanging(bool value);
  		partial void OnIsApprovedChanged();
  		
  		partial void OnLastActivityDateChanging(DateTime? value);
  		partial void OnLastActivityDateChanged();
  		
  		partial void OnLastLoginDateChanging(DateTime? value);
  		partial void OnLastLoginDateChanged();
  		
  		partial void OnLastPasswordChangedDateChanging(DateTime? value);
  		partial void OnLastPasswordChangedDateChanged();
  		
  		partial void OnCreationDateChanging(DateTime? value);
  		partial void OnCreationDateChanged();
  		
  		partial void OnIsLockedOutChanging(bool value);
  		partial void OnIsLockedOutChanged();
  		
  		partial void OnLastLockedOutDateChanging(DateTime? value);
  		partial void OnLastLockedOutDateChanged();
  		
  		partial void OnFailedPasswordAttemptCountChanging(int value);
  		partial void OnFailedPasswordAttemptCountChanged();
  		
  		partial void OnFailedPasswordAttemptWindowStartChanging(DateTime? value);
  		partial void OnFailedPasswordAttemptWindowStartChanged();
  		
  		partial void OnFailedPasswordAnswerAttemptCountChanging(int value);
  		partial void OnFailedPasswordAnswerAttemptCountChanged();
  		
  		partial void OnFailedPasswordAnswerAttemptWindowStartChanging(DateTime? value);
  		partial void OnFailedPasswordAnswerAttemptWindowStartChanged();
  		
  		partial void OnEmailAddressChanging(string value);
  		partial void OnEmailAddressChanged();
  		
  		partial void OnItemsInGridChanging(int? value);
  		partial void OnItemsInGridChanged();
  		
  		partial void OnCurrentCartChanging(string value);
  		partial void OnCurrentCartChanged();
  		
  		partial void OnMustChangePasswordChanging(bool value);
  		partial void OnMustChangePasswordChanged();
  		
  		partial void OnHostChanging(string value);
  		partial void OnHostChanged();
  		
  		partial void OnTempPasswordChanging(string value);
  		partial void OnTempPasswordChanged();
  		
  		partial void OnNameChanging(string value);
  		partial void OnNameChanged();
  		
  		partial void OnName2Changing(string value);
  		partial void OnName2Changed();
  		
  		partial void OnResetPasswordCodeChanging(Guid? value);
  		partial void OnResetPasswordCodeChanged();
  		
  		partial void OnDefaultGroupChanging(string value);
  		partial void OnDefaultGroupChanged();
  		
  		partial void OnResetPasswordExpiresChanging(DateTime? value);
  		partial void OnResetPasswordExpiresChanged();
  		
      #endregion
  		public User()
  		{
  			
  			this._Coupons = new EntitySet< Coupon>(new Action< Coupon>(this.attach_Coupons), new Action< Coupon>(this.detach_Coupons)); 
  			
  			this._SMSGroupMembers = new EntitySet< SMSGroupMember>(new Action< SMSGroupMember>(this.attach_SMSGroupMembers), new Action< SMSGroupMember>(this.detach_SMSGroupMembers)); 
  			
  			this._Preferences = new EntitySet< Preference>(new Action< Preference>(this.attach_Preferences), new Action< Preference>(this.detach_Preferences)); 
  			
  			this._UserRoles = new EntitySet< UserRole>(new Action< UserRole>(this.attach_UserRoles), new Action< UserRole>(this.detach_UserRoles)); 
  			
  			this._ApiSessions = new EntitySet< ApiSession>(new Action< ApiSession>(this.attach_ApiSessions), new Action< ApiSession>(this.detach_ApiSessions)); 
  			
  			this._VolunteerFormsUploaded = new EntitySet< VolunteerForm>(new Action< VolunteerForm>(this.attach_VolunteerFormsUploaded), new Action< VolunteerForm>(this.detach_VolunteerFormsUploaded)); 
  			
  			
  			this._Person = default(EntityRef< Person>); 
  			
  			OnCreated();
  		}
  
  		
      #region Columns
  		
  		[Column(Name="UserId", UpdateCheck=UpdateCheck.Never, Storage="_UserId", AutoSync=AutoSync.OnInsert, DbType="int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
  		public int UserId
  		{
  			get { return this._UserId; }
  
  			set
  			{
  				if (this._UserId != value)
  				{
  				
                      this.OnUserIdChanging(value);
  					this.SendPropertyChanging();
  					this._UserId = value;
  					this.SendPropertyChanged("UserId");
  					this.OnUserIdChanged();
  				}
  
  			}
  
  		}
  
  		
  		[Column(Name="PeopleId", UpdateCheck=UpdateCheck.Never, Storage="_PeopleId", DbType="int")]
  		[IsForeignKey]
  		public int? PeopleId
  		{
  
gt: 			get { return this._PeopleId; }