context: using System; 
  using System.Text; 
  using System.Data;
  using System.Data.SqlClient;
  using System.Data.Common;
  using System.Collections;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Configuration; 
  using System.Xml; 
  using System.Xml.Serialization;
  using SubSonic; 
  using SubSonic.Utilities;
  
  namespace TerritorySite.BL.CMS
  {
  	/// <summary>
  	/// Strongly-typed collection for the Language class.
  	/// </summary>
  	[Serializable]
  	public partial class LanguageCollection : ActiveList<Language, LanguageCollection> 
  	{	   
  		public LanguageCollection() {}
  
  	}
  
  	/// <summary>
  	/// This is an ActiveRecord class which wraps the Language table.
  	/// </summary>
  	[Serializable]
  	public partial class Language : ActiveRecord<Language>
  	{
  		#region .ctors and Default Settings
  		
  		public Language()
  		{
  		  SetSQLProps();
  		  InitSetDefaults();
  		  MarkNew();
  		}
  
  		
  		private void InitSetDefaults() { SetDefaults(); }
  
  		
  		public Language(bool useDatabaseDefaults)
  		{
  			SetSQLProps();
  			if(useDatabaseDefaults)
  				ForceDefaults();
  			MarkNew();
  		}
  
  		public Language(object keyID)
  		{
  			SetSQLProps();
  			InitSetDefaults();
  			LoadByKey(keyID);
  		}
  
  		 
  		public Language(string columnName, object columnValue)
  		{
  			SetSQLProps();
  			InitSetDefaults();
  			LoadByParam(columnName,columnValue);
  		}
  
  		
  		protected static void SetSQLProps() { GetTableSchema(); }
  
  		
  		#endregion
  		
  		#region Schema and Query Accessor
  		public static Query CreateQuery() { return new Query(Schema); }
  
  		
  		public static TableSchema.Table Schema
  		{
  			get
  			{
  				if (BaseSchema == null)
  					SetSQLProps();
  				return BaseSchema;
  			}
  
  		}
  
  		
  		private static void GetTableSchema() 
  		{
  			if(!IsSchemaInitialized)
  			{
  				//Schema declaration
  				TableSchema.Table schema = new TableSchema.Table("Language", TableType.Table, DataService.GetInstance("CMS"));
  				schema.Columns = new TableSchema.TableColumnCollection();
  				schema.SchemaName = @"dbo";
  				//columns
  				
  				TableSchema.TableColumn colvarLanguageId = new TableSchema.TableColumn(schema);
  				colvarLanguageId.ColumnName = "LanguageId";
  				colvarLanguageId.DataType = DbType.Int32;
  				colvarLanguageId.MaxLength = 0;
  				colvarLanguageId.AutoIncrement = true;
  				colvarLanguageId.IsNullable = false;
  				colvarLanguageId.IsPrimaryKey = true;
  				colvarLanguageId.IsForeignKey = false;
  				colvarLanguageId.IsReadOnly = false;
  				colvarLanguageId.DefaultSetting = @"";
  				colvarLanguageId.ForeignKeyTableName = "";
  				schema.Columns.Add(colvarLanguageId);
  				
  				TableSchema.TableColumn colvarDescription = new TableSchema.TableColumn(schema);
  				colvarDescription.ColumnName = "Description";
  				colvarDescription.DataType = DbType.String;
  				colvarDescription.MaxLength = 255;
  				colvarDescription.AutoIncrement = false;
  				colvarDescription.IsNullable = true;
  				colvarDescription.IsPrimaryKey = false;
  				colvarDescription.IsForeignKey = false;
  				colvarDescription.IsReadOnly = false;
  				colvarDescription.DefaultSetting = @"";
  				colvarDescription.ForeignKeyTableName = "";
  				schema.Columns.Add(colvarDescription);
  				
  				TableSchema.TableColumn colvarLanguageCode = new TableSchema.TableColumn(schema);
  				colvarLanguageCode.ColumnName = "LanguageCode";
  				colvarLanguageCode.DataType = DbType.String;
  				colvarLanguageCode.MaxLength = 10;
  				colvarLanguageCode.AutoIncrement = false;
  				colvarLanguageCode.IsNullable = true;
  				colvarLanguageCode.IsPrimaryKey = false;
  				colvarLanguageCode.IsForeignKey = false;
  				colvarLanguageCode.IsReadOnly = false;
  				colvarLanguageCode.DefaultSetting = @"";
  				colvarLanguageCode.ForeignKeyTableName = "";
  				schema.Columns.Add(colvarLanguageCode);
  				
  				BaseSchema = schema;
  				//add this schema to the provider
  				//so we can query it later
  				DataService.Providers["CMS"].AddSchema("Language",schema);
  			}
  
  		}
  
  		#endregion
  		
  		#region Props
  		
  		  
  		[XmlAttribute("LanguageId")]
  		public int LanguageId 
  		{
  			get { return GetColumnValue<int>("LanguageId"); }
  
  			set { SetColumnValue("LanguageId", value); }
  
  		}
  
  		  
  		[XmlAttribute("Description")]
  		public string Description 
  		{
  			get { return GetColumnValue<string>("Description"); }
  
  			set { SetColumnValue("Description", value); }
  
  		}
  
  		  
  		[XmlAttribute("LanguageCode")]
  		public string LanguageCode 
  		{
  			get { return GetColumnValue<string>("LanguageCode"); }
  
  			set { SetColumnValue("LanguageCode", value); }
  
  		}
  
  		
  		#endregion
  		
  		
  		#region PrimaryKey Methods
  		
  		public CMS.AccountCollection AccountRecords()
  		{
  			return new CMS.AccountCollection().Where(Account.Columns.LanguageId, LanguageId).Load();
  		}
  
  		public CMS.AddressCollection AddressRecords()
  		{
  			return new CMS.AddressCollection().Where(Address.Columns.LanguageId, LanguageId).Load();
  		}
  
  		public CMS.LanguageAccountMapCollection LanguageAccountMapRecords()
  		{
  			return new CMS.LanguageAccountMapCollection().Where(LanguageAccountMap.Columns.LanguageId, LanguageId).Load();
  		}
  
  		#endregion
  		
  			
  		
  		//no foreign key tables defined (0)
  		
  		
  		
  		//no ManyToMany tables defined (0)
  		
  		#region ObjectDataSource support
  		
  		
  		/// <summary>
  		/// Inserts a record, can be used with the Object Data Source
  		/// </summary>
  		public static void Insert(string varDescription,string varLanguageCode)
  		{
  			Language item = new Language();
  			
  			item.Description = varDescription;
  			
  			item.LanguageCode = varLanguageCode;
  			
  		
  			if (System.Web.HttpContext.Current != null)
  				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
  			else
  				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
  		}
  
  		
  		/// <summary>
  		/// Updates a record, can be used with the Object Data Source
  		/// </summary>
  		public static void Update(int varLanguageId,string varDescription,string varLanguageCode)
  		{
  			Language item = new Language();
  			
  				item.LanguageId = varLanguageId;
  				
  				item.Description = varDescription;
  				
  				item.LanguageCode = varLanguageCode;
  				
  			item.IsNew = false;
  
gt: 			if (System.Web.HttpContext.Current != null)