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 FogadooraIdopont 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("FogadooraIdopont")]
// alapértelmezett EntityHistoryMode
public class FogadooraIdopont : Entity, IFogadooraIdopont
{
internal protected FogadooraIdopont()
: base()
{
}
public class AttributeInfo
{
public const string Kezdete = "Kezdete";
public const string Vege = "Vege";
}
public class AttributeLengthInfo
{
}
#region General
private FogadooraIdopontDA m_DA = new FogadooraIdopontDA();
protected static FogadooraIdopont FakeFogadooraIdopont { get; set; }
public static FogadooraIdopont GiveAnInstance()
{
FogadooraIdopont result = FakeFogadooraIdopont == null
? new FogadooraIdopont()
: (FogadooraIdopont)FakeFogadooraIdopont.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 FogadooraIdopontDA().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 FogadooraIdopontDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters);
return result;
}
protected override void StoreOriginalValues()
{
base.StoreOriginalValues();
OriginalValues.Add("Kezdete", (object)m_Kezdete);
OriginalValues.Add("Vege", (object)m_Vege);
OriginalValues.Add("FogadooraId", (m_FogadooraId < 0 ? (object)DBNull.Value : (object)m_FogadooraId));
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...
}
// kötelező asszociációk ellenőrzése...
if (m_FogadooraId == -1) { throw new InvalidEntityAttributeException("FogadooraIdopont", "FogadooraId", EntityAttributeError.Empty); }
if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("FogadooraIdopont", "IntezmenyId", EntityAttributeError.Empty); }
if (m_TanevId == -1) { throw new InvalidEntityAttributeException("FogadooraIdopont", "TanevId", EntityAttributeError.Empty); }
}
#endregion
#region Alaphelyzetbe állítás
protected override void Reset()
{
base.Reset();
// alaphelyzetbe állítjuk az egyszerű mezőket
this.m_Kezdete = DateTime.Now /* XXX DateTime */;
this.m_Vege = DateTime.Now /* XXX DateTime */;
// alaphelyzetbe állítjuk az asszociációkból származó mezőket
this.m_FogadooraId = -1;
this.m_Fogadoora = null; // Entity
this.m_FogadooraIdopont_Gondviselo = 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...
// Fogadoora esetében mi mutatunk a másikra: startrole: *, endrole: 1
if (this.FogadooraIdopont_Gondviselo.Count > 0)
{
throw new EntityDeleteFailedException("FogadooraIdopont", "FogadooraIdopont_Gondviselo", EntityUtil.GetAssociationDescription("T_FOGADOORAIDOPONT_GONDVISELO_OSSZES", "C_FOGADOORAIDOPONTID")); // 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 Kezdete
protected internal DateTime m_Kezdete;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("Kezdete", EntityPropertyBaseType.ValueType, typeof(DateTime), EntityCopyMethod.ShallowCopy)]
public virtual DateTime Kezdete
{
get
{
return m_Kezdete;
}
set
{
CheckModifyable();
if (m_Kezdete == value) return;
m_Kezdete = value;
FieldModified("Kezdete", value);
}
}
#endregion
#region Vege
protected internal DateTime m_Vege;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("Vege", EntityPropertyBaseType.ValueType, typeof(DateTime), EntityCopyMethod.ShallowCopy)]
public virtual DateTime Vege
{
get
{
return m_Vege;
}
set
{
CheckModifyable();
if (m_Vege == value) return;
m_Vege = value;
FieldModified("Vege", value);
}
}
#endregion
#endregion
#region Asszociációkkal kapcsolatos dolgok
protected internal virtual bool LoadByFogadooraIdopont_GondviseloId(int id)
{
return m_DA.LoadByFogadooraIdopont_GondviseloId(id, this);
}
#region FogadooraIdopont (*) -> Fogadoora (1)
protected internal int m_FogadooraId = -1;
///
/// A(z) Fogadoora 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 FogadooraId
{
get
{
return InternalFogadooraId;
}
set
{
InternalFogadooraId = value;
}
}
///
/// Ez egy külön bejárat a DA számára
///
internal int InternalFogadooraId
{
get
{
if (m_Fogadoora != null)
{
return m_Fogadoora.ID;
}
else
{
return m_FogadooraId;// XXX az meg nem teljesen OK
}
}
set
{
CheckModifyable();
if (m_FogadooraId != value)
{
m_FogadooraId = value;
m_Fogadoora = null;
FieldModified("FogadooraId", value);
}
}
}
///
/// Ez egy külön bejárat a DA számára
///
internal void ModifyFogadoora(Fogadoora value)
{
m_FogadooraId = value != null ? value.ID : -1;
m_Fogadoora = value;
FieldModified("FogadooraId", value != null ? (object)value.ID : DBNull.Value);
}
protected internal void SetFogadoora(Fogadoora value)
{
m_Fogadoora = value;
if (value != null)
{
m_FogadooraId = value.ID;
}
else
{
m_FogadooraId = -1;
}
}
protected Fogadoora m_Fogadoora = null;
IFogadoora IFogadooraIdopont.Fogadoora
{
get { return Fogadoora; }
set { Fogadoora = value as Fogadoora; }
}
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő FogadooraIdopont és Fogadoora entitások közötti asszociáció megvalósítása.
///
[EntityProperty("Fogadoora", EntityPropertyBaseType.Entity, typeof(Fogadoora), EntityCopyMethod.ShallowCopy)]
public virtual Fogadoora Fogadoora
{
get
{
if ((m_Fogadoora == null) && (m_FogadooraId != -1))
{
SDA.Kreta.Entities.Fogadoora partner = SDA.Kreta.Entities.Fogadoora.GiveAnInstance();
partner.LoadByID(m_FogadooraId);
this.SetFogadoora(partner);
}
// természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit
return m_Fogadoora;
}
set
{
CheckModifyable();
if (value != null)
{
if ((m_Fogadoora == null) || (value.ID != m_Fogadoora.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.Fogadoora_FogadooraIdopont_DA da = new Fogadoora_FogadooraIdopont_DA(value);
da.AddItem(this);
this.SetFogadoora(value);
}
else
{
this.SetFogadoora(value);
}
FieldModified("FogadooraId", value.ID);
}
}
else
{
// ki kell törölni a kapcsolatot az adatbázisban
this.SetFogadoora(null);
UpdateAssociations();
FieldModified("FogadooraId", DBNull.Value);
}
}
}
#endregion
#region FogadooraIdopont (*) -> 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 IFogadooraIdopont.Intezmeny
{
get { return Intezmeny; }
set { Intezmeny = value as Intezmeny; }
}
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő FogadooraIdopont é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_FogadooraIdopont_DA da = new Intezmeny_FogadooraIdopont_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 FogadooraIdopont (*) -> 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 IFogadooraIdopont.Tanev
{
get { return Tanev; }
set { Tanev = value as Tanev; }
}
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő FogadooraIdopont é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_FogadooraIdopont_DA da = new Tanev_FogadooraIdopont_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 FogadooraIdopont (1) -> FogadooraIdopont_Gondviselo (*)
protected IAssociatedEntityCollection m_FogadooraIdopont_Gondviselo = null;
IReadOnlyList IFogadooraIdopont.FogadooraIdopont_Gondviselo => FogadooraIdopont_Gondviselo.Cast().ToList();
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő FogadooraIdopont és FogadooraIdopont_Gondviselo entitások közötti asszociáció megvalósítása.
///
[EntityProperty("FogadooraIdopont_Gondviselo", EntityPropertyBaseType.EntityCollection, typeof(IAssociatedEntityCollection), EntityCopyMethod.DeepCopy, "FogadooraIdopontId")]
public virtual IAssociatedEntityCollection FogadooraIdopont_Gondviselo
{
get
{
if (m_FogadooraIdopont_Gondviselo == null)
{
m_FogadooraIdopont_Gondviselo = new AssociatedEntityCollection(
new FogadooraIdopont_FogadooraIdopont_Gondviselo_DA(this)
);
m_FogadooraIdopont_Gondviselo.Load();
}
return m_FogadooraIdopont_Gondviselo;
}
}
#endregion
#endregion
#endregion
}
}