﻿//////////////////////////////////////////////////////////////
// <auto-generated>This code was generated by LLBLGen Pro 5.9.</auto-generated>
//////////////////////////////////////////////////////////////
// Code is generated on: 
// Code is generated using templates: SD.TemplateBindings.SharedTemplates
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using AdventureWorks.Dal.Adapter.HelperClasses;
using AdventureWorks.Dal.Adapter.FactoryClasses;
using AdventureWorks.Dal.Adapter.RelationClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace AdventureWorks.Dal.Adapter.EntityClasses
{
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END
	/// <summary>Entity class which represents the entity 'Culture'.<br/><br/></summary>
	[Serializable]
	public partial class CultureEntity : CommonEntityBase
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END	
	{
		private EntityCollection<ProductModelProductDescriptionCultureEntity> _productModelProductDescriptionCultures;

		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		private static CultureEntityStaticMetaData _staticMetaData = new CultureEntityStaticMetaData();
		private static CultureRelations _relationsFactory = new CultureRelations();

		/// <summary>All names of fields mapped onto a relation. Usable for in-memory filtering</summary>
		public static partial class MemberNames
		{
			/// <summary>Member name ProductModelProductDescriptionCultures</summary>
			public static readonly string ProductModelProductDescriptionCultures = "ProductModelProductDescriptionCultures";
		}

		/// <summary>Static meta-data storage for navigator related information</summary>
		protected class CultureEntityStaticMetaData : EntityStaticMetaDataBase
		{
			public CultureEntityStaticMetaData()
			{
				SetEntityCoreInfo("CultureEntity", InheritanceHierarchyType.None, false, (int)AdventureWorks.Dal.Adapter.EntityType.CultureEntity, typeof(CultureEntity), typeof(CultureEntityFactory), false);
				AddNavigatorMetaData<CultureEntity, EntityCollection<ProductModelProductDescriptionCultureEntity>>("ProductModelProductDescriptionCultures", a => a._productModelProductDescriptionCultures, (a, b) => a._productModelProductDescriptionCultures = b, a => a.ProductModelProductDescriptionCultures, () => new CultureRelations().ProductModelProductDescriptionCultureEntityUsingCultureId, typeof(ProductModelProductDescriptionCultureEntity), (int)AdventureWorks.Dal.Adapter.EntityType.ProductModelProductDescriptionCultureEntity);
			}
		}

		/// <summary>Static ctor</summary>
		static CultureEntity()
		{
		}

		/// <summary> CTor</summary>
		public CultureEntity()
		{
			InitClassEmpty(null, null);
		}

		/// <summary> CTor</summary>
		/// <param name="fields">Fields object to set as the fields for this entity.</param>
		public CultureEntity(IEntityFields2 fields)
		{
			InitClassEmpty(null, fields);
		}

		/// <summary> CTor</summary>
		/// <param name="validator">The custom validator object for this CultureEntity</param>
		public CultureEntity(IValidator validator)
		{
			InitClassEmpty(validator, null);
		}

		/// <summary> CTor</summary>
		/// <param name="cultureId">PK value for Culture which data should be fetched into this Culture object</param>
		public CultureEntity(System.String cultureId) : this(cultureId, null)
		{
		}

		/// <summary> CTor</summary>
		/// <param name="cultureId">PK value for Culture which data should be fetched into this Culture object</param>
		/// <param name="validator">The custom validator object for this CultureEntity</param>
		public CultureEntity(System.String cultureId, IValidator validator)
		{
			InitClassEmpty(validator, null);
			this.CultureId = cultureId;
		}

		/// <summary>Private CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected CultureEntity(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		/// <summary>Creates a new IRelationPredicateBucket object which contains the predicate expression and relation collection to fetch the related entities of type 'ProductModelProductDescriptionCulture' to this entity.</summary>
		/// <returns></returns>
		public virtual IRelationPredicateBucket GetRelationInfoProductModelProductDescriptionCultures() { return CreateRelationInfoForNavigator("ProductModelProductDescriptionCultures"); }
		
		/// <inheritdoc/>
		protected override EntityStaticMetaDataBase GetEntityStaticMetaData() {	return _staticMetaData; }

		/// <summary>Initializes the class members</summary>
		private void InitClassMembers()
		{
			PerformDependencyInjection();
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
			OnInitClassMembersComplete();
		}

		/// <summary>Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="validator">The validator object for this CultureEntity</param>
		/// <param name="fields">Fields of this entity</param>
		private void InitClassEmpty(IValidator validator, IEntityFields2 fields)
		{
			OnInitializing();
			this.Fields = fields ?? CreateFields();
			this.Validator = validator;
			InitClassMembers();
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END

			OnInitialized();
		}

		/// <summary>The relations object holding all relations of this entity with other entity classes.</summary>
		public static CultureRelations Relations { get { return _relationsFactory; } }

		/// <summary>Creates a new PrefetchPathElement2 object which contains all the information to prefetch the related entities of type 'ProductModelProductDescriptionCulture' for this entity.</summary>
		/// <returns>Ready to use IPrefetchPathElement2 implementation.</returns>
		public static IPrefetchPathElement2 PrefetchPathProductModelProductDescriptionCultures { get { return _staticMetaData.GetPrefetchPathElement("ProductModelProductDescriptionCultures", CommonEntityBase.CreateEntityCollection<ProductModelProductDescriptionCultureEntity>()); } }

		/// <summary>The CultureId property of the Entity Culture<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Culture"."CultureID".<br/>Table field type characteristics (type, precision, scale, length): NChar, 0, 0, 6.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, true, false</remarks>
		public virtual System.String CultureId
		{
			get { return (System.String)GetValue((int)CultureFieldIndex.CultureId, true); }
			set	{ SetValue((int)CultureFieldIndex.CultureId, value); }
		}

		/// <summary>The ModifiedDate property of the Entity Culture<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Culture"."ModifiedDate".<br/>Table field type characteristics (type, precision, scale, length): DateTime, 0, 0, 0.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.DateTime ModifiedDate
		{
			get { return (System.DateTime)GetValue((int)CultureFieldIndex.ModifiedDate, true); }
			set	{ SetValue((int)CultureFieldIndex.ModifiedDate, value); }
		}

		/// <summary>The Name property of the Entity Culture<br/><br/></summary>
		/// <remarks>Mapped on  table field: "Culture"."Name".<br/>Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 50.<br/>Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
		public virtual System.String Name
		{
			get { return (System.String)GetValue((int)CultureFieldIndex.Name, true); }
			set	{ SetValue((int)CultureFieldIndex.Name, value); }
		}

		/// <summary>Gets the EntityCollection with the related entities of type 'ProductModelProductDescriptionCultureEntity' which are related to this entity via a relation of type '1:n'. If the EntityCollection hasn't been fetched yet, the collection returned will be empty.<br/><br/></summary>
		[TypeContainedAttribute(typeof(ProductModelProductDescriptionCultureEntity))]
		public virtual EntityCollection<ProductModelProductDescriptionCultureEntity> ProductModelProductDescriptionCultures { get { return GetOrCreateEntityCollection<ProductModelProductDescriptionCultureEntity, ProductModelProductDescriptionCultureEntityFactory>("Culture", true, false, ref _productModelProductDescriptionCultures); } }

		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END

	}
}

namespace AdventureWorks.Dal.Adapter
{
	public enum CultureFieldIndex
	{
		///<summary>CultureId. </summary>
		CultureId,
		///<summary>ModifiedDate. </summary>
		ModifiedDate,
		///<summary>Name. </summary>
		Name,
		/// <summary></summary>
		AmountOfFields
	}
}

namespace AdventureWorks.Dal.Adapter.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: Culture. </summary>
	public partial class CultureRelations: RelationFactory
	{
		/// <summary>Returns a new IEntityRelation object, between CultureEntity and ProductModelProductDescriptionCultureEntity over the 1:n relation they have, using the relation between the fields: Culture.CultureId - ProductModelProductDescriptionCulture.CultureId</summary>
		public virtual IEntityRelation ProductModelProductDescriptionCultureEntityUsingCultureId
		{
			get { return ModelInfoProviderSingleton.GetInstance().CreateRelation(RelationType.OneToMany, "ProductModelProductDescriptionCultures", true, new[] { CultureFields.CultureId, ProductModelProductDescriptionCultureFields.CultureId }); }
		}

	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticCultureRelations
	{
		internal static readonly IEntityRelation ProductModelProductDescriptionCultureEntityUsingCultureIdStatic = new CultureRelations().ProductModelProductDescriptionCultureEntityUsingCultureId;

		/// <summary>CTor</summary>
		static StaticCultureRelations() { }
	}
}
