using System; using System.Collections.Generic; using System.Linq; using Kreta.DataAccess.Interfaces; using Kreta.Framework; using Kreta.Framework.Actions; using Kreta.Framework.Collections; using Kreta.Framework.Collections.Generic; using Kreta.Framework.Entities; using Kreta.Framework.Entities.Generic; using Kreta.Framework.Exceptions; namespace SDA.Kreta.Entities { /// /// Az UML modell DictionaryItemBase entitásának megvalósítása. /// /// A kód teljes egészében generált, kézi módosítása nem megengedett! [Entity("DictionaryItemBase")] // alapértelmezett EntityHistoryMode public class DictionaryItemBase : Entity, IDictionaryItemBase { internal protected DictionaryItemBase() : base() { } public class AttributeInfo { public const string Value = "Value"; public const string Name = "Name"; public const string Name_1 = "Name_1"; public const string Name_2 = "Name_2"; public const string Name_3 = "Name_3"; public const string Name_4 = "Name_4"; public const string Visible = "Visible"; public const string Code = "Code"; public const string Type = "Type"; public const string Protected = "Protected"; public const string Color = "Color"; public const string Order = "Order"; public const string BgColor = "BgColor"; public const string Description = "Description"; public const string IsActive = "IsActive"; public const string ShortName = "ShortName"; } public class AttributeLengthInfo { public const int NameLength = 250; public const int Name_1Length = 250; public const int Name_2Length = 250; public const int Name_3Length = 250; public const int Name_4Length = 250; public const int CodeLength = 20; public const int TypeLength = 32; public const int ColorLength = 6; public const int BgColorLength = 6; public const int DescriptionLength = 255; public const int ShortNameLength = 30; } #region General private DictionaryItemBaseDA m_DA = new DictionaryItemBaseDA(); protected static DictionaryItemBase FakeDictionaryItemBase { get; set; } public static DictionaryItemBase GiveAnInstance() { DictionaryItemBase result = FakeDictionaryItemBase == null ? new DictionaryItemBase() : (DictionaryItemBase)FakeDictionaryItemBase.MemberwiseClone(); result.Reset(); result.SetDefaultData(); return result; } protected void SetDefaultData() { if (UserContext.Instance != null) { if (UserContext.Instance.IntezmenyId > 0) { IntezmenyId = UserContext.Instance.IntezmenyId; } if (UserContext.Instance.AktivTanevId > 0) { TanevId = UserContext.Instance.AktivTanevId; } m_State = EntityState.Uninitialized; } } protected override IEntityDataAccessor GetDataAccessor() { return m_DA; } protected internal virtual IEntityDataAccessor InheritedDA { get { return null; } } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadAll() { return LoadWithFilter(""); } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadAll(ColumnFilterMode columnFilterMode, IEnumerable columns) { return LoadWithFilter("", columnFilterMode, columns); } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadWithFilter(string filter, Dictionary commandParameters = null) { var result = new EntityCollection(); new DictionaryItemBaseDA().LoadWithFilter(result, filter, commandParameters); return result; } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable columns, Dictionary commandParameters = null) { var result = new EntityCollection(); new DictionaryItemBaseDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters); return result; } protected override void StoreOriginalValues() { base.StoreOriginalValues(); OriginalValues.Add("Value", (Value == null ? (object)DBNull.Value : (object)m_Value)); OriginalValues.Add("Name", (object)m_Name); OriginalValues.Add("Name_1", (Name_1 == null ? (object)DBNull.Value : (object)m_Name_1)); OriginalValues.Add("Name_2", (Name_2 == null ? (object)DBNull.Value : (object)m_Name_2)); OriginalValues.Add("Name_3", (Name_3 == null ? (object)DBNull.Value : (object)m_Name_3)); OriginalValues.Add("Name_4", (Name_4 == null ? (object)DBNull.Value : (object)m_Name_4)); OriginalValues.Add("Visible", (object)m_Visible); OriginalValues.Add("Code", (Code == null ? (object)DBNull.Value : (object)m_Code)); OriginalValues.Add("Type", (object)m_Type); OriginalValues.Add("Protected", (object)m_Protected); OriginalValues.Add("Color", (Color == null ? (object)DBNull.Value : (object)m_Color)); OriginalValues.Add("Order", (Order == null ? (object)DBNull.Value : (object)m_Order)); OriginalValues.Add("BgColor", (BgColor == null ? (object)DBNull.Value : (object)m_BgColor)); OriginalValues.Add("Description", (Description == null ? (object)DBNull.Value : (object)m_Description)); OriginalValues.Add("IsActive", (object)m_IsActive); OriginalValues.Add("ShortName", (ShortName == null ? (object)DBNull.Value : (object)m_ShortName)); OriginalValues.Add("DictionaryTypeId", (m_DictionaryTypeId < 0 ? (object)DBNull.Value : (object)m_DictionaryTypeId)); OriginalValues.Add("IntezmenyId", (m_IntezmenyId < 0 ? (object)DBNull.Value : (object)m_IntezmenyId)); OriginalValues.Add("TanevId", (m_TanevId < 0 ? (object)DBNull.Value : (object)m_TanevId)); } #endregion #region Ellenőrzés protected override void Validate(bool skipValidateAttributes = false) { base.Validate(); if (!skipValidateAttributes) { // korlátos hosszúságú mezők ellenőrzése... if (m_Name != null && m_Name.Length > 250) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Name", EntityAttributeError.TooLong); } if (m_Name_1 != null && m_Name_1.Length > 250) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Name_1", EntityAttributeError.TooLong); } if (m_Name_2 != null && m_Name_2.Length > 250) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Name_2", EntityAttributeError.TooLong); } if (m_Name_3 != null && m_Name_3.Length > 250) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Name_3", EntityAttributeError.TooLong); } if (m_Name_4 != null && m_Name_4.Length > 250) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Name_4", EntityAttributeError.TooLong); } if (m_Code != null && m_Code.Length > 20) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Code", EntityAttributeError.TooLong); } if (m_Type != null && m_Type.Length > 32) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Type", EntityAttributeError.TooLong); } if (m_Color != null && m_Color.Length > 6) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Color", EntityAttributeError.TooLong); } if (m_BgColor != null && m_BgColor.Length > 6) { throw new InvalidEntityAttributeException("DictionaryItemBase", "BgColor", EntityAttributeError.TooLong); } if (m_Description != null && m_Description.Length > 255) { throw new InvalidEntityAttributeException("DictionaryItemBase", "Description", EntityAttributeError.TooLong); } if (m_ShortName != null && m_ShortName.Length > 30) { throw new InvalidEntityAttributeException("DictionaryItemBase", "ShortName", EntityAttributeError.TooLong); } } // kötelező asszociációk ellenőrzése... if (m_DictionaryTypeId == -1) { throw new InvalidEntityAttributeException("DictionaryItemBase", "DictionaryTypeId", EntityAttributeError.Empty); } if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("DictionaryItemBase", "IntezmenyId", EntityAttributeError.Empty); } if (m_TanevId == -1) { throw new InvalidEntityAttributeException("DictionaryItemBase", "TanevId", EntityAttributeError.Empty); } } #endregion #region Alaphelyzetbe állítás protected override void Reset() { base.Reset(); // alaphelyzetbe állítjuk az egyszerű mezőket this.m_Value = null; this.m_Name = ""; this.m_Name_1 = null; this.m_Name_2 = null; this.m_Name_3 = null; this.m_Name_4 = null; this.m_Visible = true; this.m_Code = null; this.m_Type = ""; this.m_Protected = true; this.m_Color = null; this.m_Order = null; this.m_BgColor = null; this.m_Description = null; this.m_IsActive = true; this.m_ShortName = null; // alaphelyzetbe állítjuk az asszociációkból származó mezőket this.m_DictionaryTypeId = -1; this.m_DictionaryType = null; // Entity this.m_DictionaryItemBaseNyelv = null; // EntityCollection this.m_IntezmenyId = -1; this.m_Intezmeny = null; // Entity this.m_TanevId = -1; this.m_Tanev = null; // Entity } #endregion protected override void DeAssociateBeforeDelete(bool runHandler = false) { // Nem kaszkád törölhető asszociációk ellenőrzése, hogy üresek-e... // DictionaryType esetében mi mutatunk a másikra: startrole: *, endrole: 1 if (this.DictionaryItemBaseNyelv.Count > 0) { throw new EntityDeleteFailedException("DictionaryItemBase", "DictionaryItemBaseNyelv", EntityUtil.GetAssociationDescription("T_DICTIONARYITEMBASENYELV_OSSZES", "C_DICTIONARYITEMBASEID")); // nincs kapcsolotabla } // Intezmeny esetében mi mutatunk a másikra: startrole: *, endrole: 1 // Tanev esetében mi mutatunk a másikra: startrole: *, endrole: 1 // kaszkád törlések... } #region Mezők és tulajdonságok #region Egyszerű mezők #region Value protected internal int? m_Value; /// /// DictionaryItem-ek ?rt?k?t meghat?roz? attrib?tum. Ha nincs a DictionaryItem-nek ?rt?ke, akkor tetszoleges ?rt?k t?rol?s?ra szolg?l. /// [EntityProperty("Value", EntityPropertyBaseType.ValueType, typeof(int), EntityCopyMethod.ShallowCopy)] public virtual int? Value { get { return m_Value; } set { CheckModifyable(); if (m_Value == value) return; m_Value = value; FieldModified("Value", value); } } #endregion #region Name protected internal string m_Name; /// /// DictionaryItem megnevez?s?nek t?rol?s?ra szolg?l? attrib?tum /// [EntityProperty("Name", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name { get { return m_Name; } set { CheckModifyable(); if (m_Name == value) return; m_Name = value; FieldModified("Name", value); } } /// /// A(z) Name értéke a jelenlegi nyelven. Csak megjelenítéshez használni! /// public string GetName() { return GetName(EntityUtil.CurrentLanguageIndex); } private string GetName(int languageIndex) { switch (languageIndex) { case 1: { return (string.IsNullOrEmpty(Name_1) ? Name : Name_1); } case 2: { return (string.IsNullOrEmpty(Name_2) ? Name : Name_2); } case 3: { return (string.IsNullOrEmpty(Name_3) ? Name : Name_3); } case 4: { return (string.IsNullOrEmpty(Name_4) ? Name : Name_4); } default: { return Name; } } } #endregion #region Name_1 protected internal string m_Name_1; /// /// DictionaryItem megnevez?s?nek t?rol?s?ra szolg?l? attrib?tum /// [EntityProperty("Name_1", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_1 { get { return m_Name_1; } set { CheckModifyable(); if (m_Name_1 == value) return; m_Name_1 = value; FieldModified("Name_1", value); } } #endregion #region Name_2 protected internal string m_Name_2; /// /// DictionaryItem megnevez?s?nek t?rol?s?ra szolg?l? attrib?tum /// [EntityProperty("Name_2", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_2 { get { return m_Name_2; } set { CheckModifyable(); if (m_Name_2 == value) return; m_Name_2 = value; FieldModified("Name_2", value); } } #endregion #region Name_3 protected internal string m_Name_3; /// /// DictionaryItem megnevez?s?nek t?rol?s?ra szolg?l? attrib?tum /// [EntityProperty("Name_3", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_3 { get { return m_Name_3; } set { CheckModifyable(); if (m_Name_3 == value) return; m_Name_3 = value; FieldModified("Name_3", value); } } #endregion #region Name_4 protected internal string m_Name_4; /// /// DictionaryItem megnevez?s?nek t?rol?s?ra szolg?l? attrib?tum /// [EntityProperty("Name_4", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_4 { get { return m_Name_4; } set { CheckModifyable(); if (m_Name_4 == value) return; m_Name_4 = value; FieldModified("Name_4", value); } } #endregion #region Visible protected internal bool m_Visible; /// /// K?pernyon l?that?-e. /// [EntityProperty("Visible", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)] public virtual bool Visible { get { return m_Visible; } set { CheckModifyable(); if (m_Visible == value) return; m_Visible = value; FieldModified("Visible", value); } } #endregion #region Code protected internal string m_Code; /// /// A kodtetel kodja, ha van /// [EntityProperty("Code", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Code { get { return m_Code; } set { CheckModifyable(); if (m_Code == value) return; m_Code = value; FieldModified("Code", value); } } #endregion #region Type protected internal string m_Type; /// /// Kapcsolodo kodtetel tipus neve /// [EntityProperty("Type", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Type { get { return m_Type; } set { // readonly attribútum CheckModifyable(); if (m_Type == null || this.ID <= 0) { m_Type = value; FieldModified("Type", value); } else { throw new ReadOnlyEntityAttributeException("DictionaryItemBase", "Type"); } } } #endregion #region Protected protected internal bool m_Protected; /// /// v?dett /// [EntityProperty("Protected", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)] public virtual bool Protected { get { return m_Protected; } set { CheckModifyable(); if (m_Protected == value) return; m_Protected = value; FieldModified("Protected", value); } } #endregion #region Color protected internal string m_Color; /// /// szín /// [EntityProperty("Color", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Color { get { return m_Color; } set { CheckModifyable(); if (m_Color == value) return; m_Color = value; FieldModified("Color", value); } } #endregion #region Order protected internal int? m_Order; /// /// sorrend /// [EntityProperty("Order", EntityPropertyBaseType.ValueType, typeof(int), EntityCopyMethod.ShallowCopy)] public virtual int? Order { get { return m_Order; } set { CheckModifyable(); if (m_Order == value) return; m_Order = value; FieldModified("Order", value); } } #endregion #region BgColor protected internal string m_BgColor; /// /// Az elem háttérszíne /// [EntityProperty("BgColor", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string BgColor { get { return m_BgColor; } set { CheckModifyable(); if (m_BgColor == value) return; m_BgColor = value; FieldModified("BgColor", value); } } #endregion #region Description protected internal string m_Description; /// /// Leírás /// [EntityProperty("Description", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Description { get { return m_Description; } set { CheckModifyable(); if (m_Description == value) return; m_Description = value; FieldModified("Description", value); } } #endregion #region IsActive protected internal bool m_IsActive; /// /// Az elem használatban van-e, adható-e értékül-e. /// [EntityProperty("IsActive", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)] public virtual bool IsActive { get { return m_IsActive; } set { CheckModifyable(); if (m_IsActive == value) return; m_IsActive = value; FieldModified("IsActive", value); } } #endregion #region ShortName protected internal string m_ShortName; /// /// Az elem rövid neve /// [EntityProperty("ShortName", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string ShortName { get { return m_ShortName; } set { CheckModifyable(); if (m_ShortName == value) return; m_ShortName = value; FieldModified("ShortName", value); } } #endregion #endregion #region Asszociációkkal kapcsolatos dolgok protected internal virtual bool LoadByDictionaryItemBaseNyelvId(int id) { return m_DA.LoadByDictionaryItemBaseNyelvId(id, this); } #region DictionaryItemBase (*) -> DictionaryType (1) protected internal int m_DictionaryTypeId = -1; /// /// A(z) DictionaryType asszociáció végpontjának ID-ja. /// /// /// - Insert() előtt célszerű kitölteni /// - Update() nincs rá hatással: ezt a mezőt nem frissíti /// - LoadByID() felhozza ezt a mezőt /// public virtual int DictionaryTypeId { get { return InternalDictionaryTypeId; } set { InternalDictionaryTypeId = value; } } /// /// Ez egy külön bejárat a DA számára /// internal int InternalDictionaryTypeId { get { if (m_DictionaryType != null) { return m_DictionaryType.ID; } else { return m_DictionaryTypeId;// XXX az meg nem teljesen OK } } set { CheckModifyable(); if (m_DictionaryTypeId != value) { m_DictionaryTypeId = value; m_DictionaryType = null; FieldModified("DictionaryTypeId", value); } } } /// /// Ez egy külön bejárat a DA számára /// internal void ModifyDictionaryType(DictionaryType value) { m_DictionaryTypeId = value != null ? value.ID : -1; m_DictionaryType = value; FieldModified("DictionaryTypeId", value != null ? (object)value.ID : DBNull.Value); } protected internal void SetDictionaryType(DictionaryType value) { m_DictionaryType = value; if (value != null) { m_DictionaryTypeId = value.ID; } else { m_DictionaryTypeId = -1; } } protected DictionaryType m_DictionaryType = null; IDictionaryType IDictionaryItemBase.DictionaryType { get { return DictionaryType; } set { DictionaryType = value as DictionaryType; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBase és DictionaryType entitások közötti asszociáció megvalósítása. /// [EntityProperty("DictionaryType", EntityPropertyBaseType.Entity, typeof(DictionaryType), EntityCopyMethod.ShallowCopy)] public virtual DictionaryType DictionaryType { get { if ((m_DictionaryType == null) && (m_DictionaryTypeId != -1)) { SDA.Kreta.Entities.DictionaryType partner = SDA.Kreta.Entities.DictionaryType.GiveAnInstance(); partner.LoadByID(m_DictionaryTypeId); this.SetDictionaryType(partner); } // természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit return m_DictionaryType; } set { CheckModifyable(); if (value != null) { if ((m_DictionaryType == null) || (value.ID != m_DictionaryType.ID)) { if (value.State != EntityState.Initialized) { throw new EntityStateException(value.State); } if ((this.State != EntityState.New)) { // Lista van a másik oldalon, úgyhogy a lista DA-ját használjuk SDA.Kreta.Entities.DictionaryType_DictionaryItemBase_DA da = new DictionaryType_DictionaryItemBase_DA(value); da.AddItem(this); this.SetDictionaryType(value); } else { this.SetDictionaryType(value); } FieldModified("DictionaryTypeId", value.ID); } } else { // ki kell törölni a kapcsolatot az adatbázisban this.SetDictionaryType(null); UpdateAssociations(); FieldModified("DictionaryTypeId", DBNull.Value); } } } #endregion #region DictionaryItemBase (*) -> Intezmeny (1) protected internal int m_IntezmenyId = -1; /// /// A(z) Intezmeny asszociáció végpontjának ID-ja. /// /// /// - Insert() előtt célszerű kitölteni /// - Update() nincs rá hatással: ezt a mezőt nem frissíti /// - LoadByID() felhozza ezt a mezőt /// public virtual int IntezmenyId { get { return InternalIntezmenyId; } set { InternalIntezmenyId = value; } } /// /// Ez egy külön bejárat a DA számára /// internal int InternalIntezmenyId { get { if (m_Intezmeny != null) { return m_Intezmeny.ID; } else { return m_IntezmenyId;// XXX az meg nem teljesen OK } } set { CheckModifyable(); if (m_IntezmenyId != value) { m_IntezmenyId = value; m_Intezmeny = null; FieldModified("IntezmenyId", value); } } } /// /// Ez egy külön bejárat a DA számára /// internal void ModifyIntezmeny(Intezmeny value) { m_IntezmenyId = value != null ? value.ID : -1; m_Intezmeny = value; FieldModified("IntezmenyId", value != null ? (object)value.ID : DBNull.Value); } protected internal void SetIntezmeny(Intezmeny value) { m_Intezmeny = value; if (value != null) { m_IntezmenyId = value.ID; } else { m_IntezmenyId = -1; } } protected Intezmeny m_Intezmeny = null; IIntezmeny IDictionaryItemBase.Intezmeny { get { return Intezmeny; } set { Intezmeny = value as Intezmeny; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBase és Intezmeny entitások közötti asszociáció megvalósítása. /// [EntityProperty("Intezmeny", EntityPropertyBaseType.Entity, typeof(Intezmeny), EntityCopyMethod.ShallowCopy)] public virtual Intezmeny Intezmeny { get { if ((m_Intezmeny == null) && (m_IntezmenyId != -1)) { SDA.Kreta.Entities.Intezmeny partner = SDA.Kreta.Entities.Intezmeny.GiveAnInstance(); partner.LoadByID(m_IntezmenyId); this.SetIntezmeny(partner); } // természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit return m_Intezmeny; } set { CheckModifyable(); if (value != null) { if ((m_Intezmeny == null) || (value.ID != m_Intezmeny.ID)) { if (value.State != EntityState.Initialized) { throw new EntityStateException(value.State); } if ((this.State != EntityState.New)) { // Lista van a másik oldalon, úgyhogy a lista DA-ját használjuk SDA.Kreta.Entities.Intezmeny_DictionaryItemBase_DA da = new Intezmeny_DictionaryItemBase_DA(value); da.AddItem(this); this.SetIntezmeny(value); } else { this.SetIntezmeny(value); } FieldModified("IntezmenyId", value.ID); } } else { // ki kell törölni a kapcsolatot az adatbázisban this.SetIntezmeny(null); UpdateAssociations(); FieldModified("IntezmenyId", DBNull.Value); } } } #endregion #region DictionaryItemBase (*) -> Tanev (1) protected internal int m_TanevId = -1; /// /// A(z) Tanev asszociáció végpontjának ID-ja. /// /// /// - Insert() előtt célszerű kitölteni /// - Update() nincs rá hatással: ezt a mezőt nem frissíti /// - LoadByID() felhozza ezt a mezőt /// public virtual int TanevId { get { return InternalTanevId; } set { InternalTanevId = value; } } /// /// Ez egy külön bejárat a DA számára /// internal int InternalTanevId { get { if (m_Tanev != null) { return m_Tanev.ID; } else { return m_TanevId;// XXX az meg nem teljesen OK } } set { CheckModifyable(); if (m_TanevId != value) { m_TanevId = value; m_Tanev = null; FieldModified("TanevId", value); } } } /// /// Ez egy külön bejárat a DA számára /// internal void ModifyTanev(Tanev value) { m_TanevId = value != null ? value.ID : -1; m_Tanev = value; FieldModified("TanevId", value != null ? (object)value.ID : DBNull.Value); } protected internal void SetTanev(Tanev value) { m_Tanev = value; if (value != null) { m_TanevId = value.ID; } else { m_TanevId = -1; } } protected Tanev m_Tanev = null; ITanev IDictionaryItemBase.Tanev { get { return Tanev; } set { Tanev = value as Tanev; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBase és Tanev entitások közötti asszociáció megvalósítása. /// [EntityProperty("Tanev", EntityPropertyBaseType.Entity, typeof(Tanev), EntityCopyMethod.ShallowCopy)] public virtual Tanev Tanev { get { if ((m_Tanev == null) && (m_TanevId != -1)) { SDA.Kreta.Entities.Tanev partner = SDA.Kreta.Entities.Tanev.GiveAnInstance(); partner.LoadByID(m_TanevId); this.SetTanev(partner); } // természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit return m_Tanev; } set { CheckModifyable(); if (value != null) { if ((m_Tanev == null) || (value.ID != m_Tanev.ID)) { if (value.State != EntityState.Initialized) { throw new EntityStateException(value.State); } if ((this.State != EntityState.New)) { // Lista van a másik oldalon, úgyhogy a lista DA-ját használjuk SDA.Kreta.Entities.Tanev_DictionaryItemBase_DA da = new Tanev_DictionaryItemBase_DA(value); da.AddItem(this); this.SetTanev(value); } else { this.SetTanev(value); } FieldModified("TanevId", value.ID); } } else { // ki kell törölni a kapcsolatot az adatbázisban this.SetTanev(null); UpdateAssociations(); FieldModified("TanevId", DBNull.Value); } } } #endregion #region DictionaryItemBase (1) -> DictionaryItemBaseNyelv (0..*) protected IAssociatedEntityCollection m_DictionaryItemBaseNyelv = null; IReadOnlyList IDictionaryItemBase.DictionaryItemBaseNyelv => DictionaryItemBaseNyelv.Cast().ToList(); /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBase és DictionaryItemBaseNyelv entitások közötti asszociáció megvalósítása. /// [EntityProperty("DictionaryItemBaseNyelv", EntityPropertyBaseType.EntityCollection, typeof(IAssociatedEntityCollection), EntityCopyMethod.DeepCopy, "DictionaryItemBaseId")] public virtual IAssociatedEntityCollection DictionaryItemBaseNyelv { get { if (m_DictionaryItemBaseNyelv == null) { m_DictionaryItemBaseNyelv = new AssociatedEntityCollection( new DictionaryItemBase_DictionaryItemBaseNyelv_DA(this) ); m_DictionaryItemBaseNyelv.Load(); } return m_DictionaryItemBaseNyelv; } } #endregion #endregion #endregion } }