using System; using System.Collections.Generic; using System.Data; using System.Linq; using Kreta.Framework; using Kreta.Framework.Collections; using Kreta.Framework.Collections.Generic; using Kreta.Framework.Entities; using Kreta.Framework.Entities.Associations; using Kreta.Framework.Entities.Generic; namespace SDA.Kreta.Entities { internal sealed class FogadooraIdopont_GondviseloDBHelper : EntityDBHelper { private Dictionary dynamicColumns = new Dictionary() { }; private const string dynamicQueryCommandText = "select " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.ID, " + "{COLUMNS}" + // FogadooraIdopont_Gondviselo betöltése // FogadooraIdopont_Gondviselo kapcsoló mezői "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_FOGADOORAIDOPONTID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_GONDVISELOID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.TOROLT, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.SERIAL, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.CREATED, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.CREATOR, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.LASTCHANGED, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.MODIFIER " + "from " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES " + "where " + "(1 = 1) "; private const string emptyQueryCommandText = "select " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.ID, " + // FogadooraIdopont_Gondviselo betöltése // FogadooraIdopont_Gondviselo mezői // FogadooraIdopont_Gondviselo kapcsoló mezői "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_FOGADOORAIDOPONTID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_GONDVISELOID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */ "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.TOROLT, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.SERIAL, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.CREATED, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.CREATOR, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.LASTCHANGED, " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.MODIFIER " + "from " + "T_FOGADOORAIDOPONT_GONDVISELO_OSSZES " + "where " + "(1 = 1) "; public override string EmptyQueryCommandText { get { return emptyQueryCommandText; } } public override string DynamicQueryCommandText { get { return dynamicQueryCommandText; } } public override IDictionary DynamicColumns { get { return dynamicColumns; } } protected override FogadooraIdopont_Gondviselo CreateEntityInstance() { return FogadooraIdopont_Gondviselo.GiveAnInstance(); } #region Lekérdezés public override void LoadEntityFields(FogadooraIdopont_Gondviselo entity, SDA.DataProvider.SDADataReader reader) { // FogadooraIdopont_Gondviselo betöltése // FogadooraIdopont_Gondviselo mezői // FogadooraIdopont_Gondviselo kapcsoló mezői DAUtil.ReadIDAttribute(reader, 1, ref entity.m_FogadooraIdopontId, 0); DAUtil.ReadIDAttribute(reader, 2, ref entity.m_GondviseloId, 0); DAUtil.ReadIDAttribute(reader, 3, ref entity.m_IntezmenyId, 0); DAUtil.ReadIDAttribute(reader, 4, ref entity.m_TanevId, 0); } public override void LoadEntityFields(FogadooraIdopont_Gondviselo entity, SDA.DataProvider.SDADataReader reader, ColumnFilterMode columnFilterMode, IEnumerable columns) { int index = 1; if (columns == null) { columns = new List(index); } // FogadooraIdopont_Gondviselo betöltése // FogadooraIdopont_Gondviselo mezői // FogadooraIdopont_Gondviselo kapcsoló mezői DAUtil.ReadIDAttribute(reader, index++, ref entity.m_FogadooraIdopontId, 0); DAUtil.ReadIDAttribute(reader, index++, ref entity.m_GondviseloId, 0); DAUtil.ReadIDAttribute(reader, index++, ref entity.m_IntezmenyId, 0); DAUtil.ReadIDAttribute(reader, index++, ref entity.m_TanevId, 0); } #endregion #region Paraméter kötés public override void BindAttributes(FogadooraIdopont_Gondviselo entity, SDA.DataProvider.SDACommand command) { } public override void DynamicBindAttributes(FogadooraIdopont_Gondviselo entity, SDA.DataProvider.SDACommand command) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); command.CommandText = command.CommandText.Replace("{COLUMNS}", sb.ToString()); } public override void BindAssociations(FogadooraIdopont_Gondviselo entity, SDA.DataProvider.SDACommand command) { DAUtil.BindIdParameter(command, "pFOGADOORAIDOPONTID", entity.InternalFogadooraIdopontId); DAUtil.BindIdParameter(command, "pGONDVISELOID", entity.InternalGondviseloId); DAUtil.BindIdParameter(command, "pINTEZMENYID", entity.InternalIntezmenyId); DAUtil.BindIdParameter(command, "pTANEVID", entity.InternalTanevId); } #endregion } internal class FogadooraIdopont_GondviseloDA : EntityDataAccessor { private static FogadooraIdopont_GondviseloDBHelper m_dbhelper = new FogadooraIdopont_GondviseloDBHelper(); protected override IEntityDBHelper dbhelper { get { return m_dbhelper; } } #region Load public override bool LoadEntity(FogadooraIdopont_Gondviselo entity, int entityId) { return LoadById(entity, entityId); } public override bool FilteredLoadEntity(FogadooraIdopont_Gondviselo entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable columns) { return LoadById(entity, entityId, columnFilterMode, columns); } public bool LoadById(FogadooraIdopont_Gondviselo entity, int entityId) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand()) { command.CommandText += " and (T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.ID = :pID) "; command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entityId; return dbhelper.LoadSingleEntity(entity, command); } } public bool LoadById(FogadooraIdopont_Gondviselo entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable columns) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateDynamicQueryCommand(columnFilterMode, columns)) { command.CommandText += " and (T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.ID = :pID) "; command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entityId; return dbhelper.LoadSingleEntity(entity, command, 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 override void LoadWithFilter(IEntityCollection collection, string filter, Dictionary commandParameters = null) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand()) { command.CommandText += filter; dbhelper.CreateParameterBinding(command, commandParameters); dbhelper.LoadEntityCollection(collection, command); } } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public override void LoadWithFilter(IEntityCollection collection, string filter, ColumnFilterMode columnFilterMode, IEnumerable columns, Dictionary commandParameters = null) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateDynamicQueryCommand(columnFilterMode, columns)) { command.CommandText += filter; dbhelper.CreateParameterBinding(command, commandParameters); dbhelper.LoadEntityCollection(collection, command, columnFilterMode, columns); } } #endregion #region InsertEntity private const string m_InsertCommandText = @" insert into T_FOGADOORAIDOPONT_GONDVISELO_OSSZES ( C_FOGADOORAIDOPONTID, C_GONDVISELOID, C_INTEZMENYID, C_TANEVID, TOROLT, SERIAL, CREATED, CREATOR) values ( :pFOGADOORAIDOPONTID, :pGONDVISELOID, :pINTEZMENYID, :pTANEVID, :pTOROLT, :pSERIAL, :pCREATED, :pCREATOR); SELECT SCOPE_IDENTITY() as ID; "; public override void InsertEntity(FogadooraIdopont_Gondviselo entity) { entity.Serial = 0; SetEntityCreator(entity, DateTime.Now, UserContext.Instance.UniqueIdentifier); using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_InsertCommandText)) { dbhelper.BindAttributes(entity, command); dbhelper.BindAssociations(entity, command); command.Parameters.Add("pTOROLT", SDA.DataProvider.SDADBType.Boolean /* Boolean */).Value = false; command.Parameters.Add("pSERIAL", SDA.DataProvider.SDADBType.Int).Value = 0; command.Parameters.Add("pCREATED", SDA.DataProvider.SDADBType.DateTime).Value = entity.EntityCreated; command.Parameters.Add("pCREATOR", SDA.DataProvider.SDADBType.Int).Value = entity.EntityCreator; entity.ID = Convert.ToInt32(command.ExecuteScalar()); } } #endregion #region UpdateEntity private const string m_UpdateAttributesCommandText = @" update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set {COLUMNS} SERIAL = ISNULL(SERIAL,0) + 1, LASTCHANGED = :pLASTCHANGED, MODIFIER = :pMODIFIER, TOROLT = :pTOROLT where (ID = :pID) and (ISNULL(SERIAL,0) = :pSERIAL) "; public override bool UpdateEntity(FogadooraIdopont_Gondviselo entity) { using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_UpdateAttributesCommandText)) { bool result = true; dbhelper.DynamicBindAttributes(entity, command); SetEntityModifier(entity, DateTime.Now, UserContext.Instance.UniqueIdentifier); command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entity.ID; command.Parameters.Add("pSERIAL", SDA.DataProvider.SDADBType.Int).Value = entity.Serial; command.Parameters.Add("pLASTCHANGED", SDA.DataProvider.SDADBType.DateTime).Value = entity.EntityLastChanged; command.Parameters.Add("pMODIFIER", SDA.DataProvider.SDADBType.Int).Value = entity.EntityModifier; command.Parameters.Add("pTOROLT", SDA.DataProvider.SDADBType.Boolean /* Boolean */).Value = entity.Torolt; result = (command.ExecuteNonQuery() == 1); if (result == true) entity.Serial++; return result; } } #endregion #region DeleteEntity private const string m_FizikaiDeleteCommandText = @"DELETE FROM T_FOGADOORAIDOPONT_GONDVISELO_OSSZES WHERE (ID = :pID) "; private const string m_LogikaiDeleteCommandText = @" UPDATE T_FOGADOORAIDOPONT_GONDVISELO_OSSZES SET TOROLT = 'T' , SERIAL = SERIAL + 1, LASTCHANGED = :pLASTCHANGED, MODIFIER = :pMODIFIER WHERE (ID = :pID) "; public override void DeleteEntity(FogadooraIdopont_Gondviselo entity, bool logikai = true) { var _deleteCommandText = logikai ? m_LogikaiDeleteCommandText : m_FizikaiDeleteCommandText; using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(_deleteCommandText)) { command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entity.ID; if (logikai) { DateTime lastchanged = DateTime.Now; var modifier = UserContext.Instance.UniqueIdentifier; command.Parameters.Add("pLASTCHANGED", SDA.DataProvider.SDADBType.DateTime).Value = lastchanged; command.Parameters.Add("pMODIFIER", SDA.DataProvider.SDADBType.Int).Value = modifier; } if (command.ExecuteNonQuery() != 1) { throw new EntityNotFoundException("FogadooraIdopont_Gondviselo", entity.ID); } } } #endregion #region UpdateAssociations private const string m_UpdateAssociationCommandText = @" update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_FOGADOORAIDOPONTID = :pFOGADOORAIDOPONTID, C_GONDVISELOID = :pGONDVISELOID, C_INTEZMENYID = :pINTEZMENYID, C_TANEVID = :pTANEVID, SERIAL = ISNULL(SERIAL,0) + 1, LASTCHANGED = :pLASTCHANGED, MODIFIER = :pMODIFIER where (ID = :pID) and (ISNULL(SERIAL,0) = :pSERIAL) "; public override bool UpdateAssociations(FogadooraIdopont_Gondviselo entity) { using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_UpdateAssociationCommandText)) { dbhelper.BindAssociations(entity, command); DateTime lastchanged = DateTime.Now; var modifier = UserContext.Instance.UniqueIdentifier; command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entity.ID; command.Parameters.Add("pSERIAL", SDA.DataProvider.SDADBType.Int).Value = entity.Serial; command.Parameters.Add("pLASTCHANGED", SDA.DataProvider.SDADBType.DateTime).Value = lastchanged; command.Parameters.Add("pMODIFIER", SDA.DataProvider.SDADBType.Int).Value = modifier; bool result = (command.ExecuteNonQuery() == 1); if (result == true) { entity.Serial++; SetEntityModifier(entity, lastchanged, modifier); } return result; } } #endregion #region Asszociációkkal kapcsolatos adatbázisműveletek (entitásspecifikus) #region Mint asszociációs osztály #endregion #endregion } /// /// Az osztály elvégzi az UML modell 'FogadooraIdopont -> FogadooraIdopont_Gondviselo (FogadooraIdopont_Gondviselo)' /// asszociációjának teljes kezelését. /// internal class FogadooraIdopont_FogadooraIdopont_Gondviselo_DA : EntityCollectionDA { internal protected FogadooraIdopont_FogadooraIdopont_Gondviselo_DA(FogadooraIdopont owner) : base(owner) { } // Nincs kapcsolótábla private const string m_Filter = @" and (T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_FOGADOORAIDOPONTID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new FogadooraIdopont_GondviseloDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } private static SDA.DataProvider.SDACommand CreateInsertFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_FOGADOORAIDOPONTID = :pFOGADOORAIDOPONTID where (ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pFOGADOORAIDOPONTID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoAdd(FogadooraIdopont owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateInsertFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pFOGADOORAIDOPONTID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void AddItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_FogadooraIdopont"); assochandler.BeforeInsert(entity, this.Owner); entity.ModifyFogadooraIdopont(this.Owner); if (entity.State == EntityState.Modified) { entity.UpdateAssociations(true); } else { entity.Insert(true); } assochandler.AfterInsert(entity, this.Owner); } private static SDA.DataProvider.SDACommand CreateDeleteFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_FOGADOORAIDOPONTID = null where (C_FOGADOORAIDOPONTID = :pFOGADOORAIDOPONTID and ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pFOGADOORAIDOPONTID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoRemove(FogadooraIdopont owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateDeleteFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pFOGADOORAIDOPONTID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void DeleteItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_FogadooraIdopont"); assochandler.BeforeDelete(entity, this.Owner); entity.Delete(true); assochandler.AfterDelete(entity, this.Owner); } } /// /// Az osztály elvégzi az UML modell 'Gondviselo -> FogadooraIdopont_Gondviselo (FogadooraIdopont_Gondviselo)' /// asszociációjának teljes kezelését. /// internal class Gondviselo_FogadooraIdopont_Gondviselo_DA : EntityCollectionDA { internal protected Gondviselo_FogadooraIdopont_Gondviselo_DA(Gondviselo owner) : base(owner) { } // Nincs kapcsolótábla private const string m_Filter = @" and (T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_GONDVISELOID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new FogadooraIdopont_GondviseloDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } private static SDA.DataProvider.SDACommand CreateInsertFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_GONDVISELOID = :pGONDVISELOID where (ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pGONDVISELOID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoAdd(Gondviselo owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateInsertFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pGONDVISELOID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void AddItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_Gondviselo"); assochandler.BeforeInsert(entity, this.Owner); entity.ModifyGondviselo(this.Owner); if (entity.State == EntityState.Modified) { entity.UpdateAssociations(true); } else { entity.Insert(true); } assochandler.AfterInsert(entity, this.Owner); } private static SDA.DataProvider.SDACommand CreateDeleteFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_GONDVISELOID = null where (C_GONDVISELOID = :pGONDVISELOID and ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pGONDVISELOID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoRemove(Gondviselo owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateDeleteFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pGONDVISELOID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void DeleteItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_Gondviselo"); assochandler.BeforeDelete(entity, this.Owner); entity.Delete(true); assochandler.AfterDelete(entity, this.Owner); } } /// /// Az osztály elvégzi az UML modell 'Intezmeny -> FogadooraIdopont_Gondviselo (FogadooraIdopont_Gondviselo)' /// asszociációjának teljes kezelését. /// internal class Intezmeny_FogadooraIdopont_Gondviselo_DA : EntityCollectionDA { internal protected Intezmeny_FogadooraIdopont_Gondviselo_DA(Intezmeny owner) : base(owner) { } // Nincs kapcsolótábla private const string m_Filter = @" and (T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_INTEZMENYID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new FogadooraIdopont_GondviseloDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } private static SDA.DataProvider.SDACommand CreateInsertFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_INTEZMENYID = :pINTEZMENYID where (ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoAdd(Intezmeny owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateInsertFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pINTEZMENYID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void AddItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_Intezmeny"); assochandler.BeforeInsert(entity, this.Owner); entity.ModifyIntezmeny(this.Owner); if (entity.State == EntityState.Modified) { entity.UpdateAssociations(true); } else { entity.Insert(true); } assochandler.AfterInsert(entity, this.Owner); } private static SDA.DataProvider.SDACommand CreateDeleteFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_INTEZMENYID = null where (C_INTEZMENYID = :pINTEZMENYID and ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoRemove(Intezmeny owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateDeleteFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pINTEZMENYID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void DeleteItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_Intezmeny"); assochandler.BeforeDelete(entity, this.Owner); entity.Delete(true); assochandler.AfterDelete(entity, this.Owner); } } /// /// Az osztály elvégzi az UML modell 'Tanev -> FogadooraIdopont_Gondviselo (FogadooraIdopont_Gondviselo)' /// asszociációjának teljes kezelését. /// internal class Tanev_FogadooraIdopont_Gondviselo_DA : EntityCollectionDA { internal protected Tanev_FogadooraIdopont_Gondviselo_DA(Tanev owner) : base(owner) { } // Nincs kapcsolótábla private const string m_Filter = @" and (T_FOGADOORAIDOPONT_GONDVISELO_OSSZES.C_TANEVID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new FogadooraIdopont_GondviseloDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } private static SDA.DataProvider.SDACommand CreateInsertFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_TANEVID = :pTANEVID where (ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoAdd(Tanev owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateInsertFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pTANEVID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void AddItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_Tanev"); assochandler.BeforeInsert(entity, this.Owner); entity.ModifyTanev(this.Owner); if (entity.State == EntityState.Modified) { entity.UpdateAssociations(true); } else { entity.Insert(true); } assochandler.AfterInsert(entity, this.Owner); } private static SDA.DataProvider.SDACommand CreateDeleteFogadooraIdopont_GondviseloCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_FOGADOORAIDOPONT_GONDVISELO_OSSZES set C_TANEVID = null where (C_TANEVID = :pTANEVID and ID = :pFOGADOORAIDOPONT_GONDVISELOID)"; result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pFOGADOORAIDOPONT_GONDVISELOID", SDA.DataProvider.SDADBType.Int); return result; } private void DoRemove(Tanev owner, FogadooraIdopont_Gondviselo partner) { using (SDA.DataProvider.SDACommand command = CreateDeleteFogadooraIdopont_GondviseloCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pTANEVID"].Value = owner.ID; command.Parameters["pFOGADOORAIDOPONT_GONDVISELOID"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void DeleteItem(FogadooraIdopont_Gondviselo entity) { var assochandler = AssociationHandlerManager.Create("FogadooraIdopont_Gondviselo_Tanev"); assochandler.BeforeDelete(entity, this.Owner); entity.Delete(true); assochandler.AfterDelete(entity, this.Owner); } } }