public void Delete() { if (this.Context != null) { if (this.ObjDAL != null && this.ObjDAL.EntityKey != null) { if (this.ObjDAL.EntityState == System.Data.EntityState.Detached) { this.Context.Context.Attach(this.ObjDAL); this.Context.Context.DeleteObject(this.ObjDAL); } else { this.Context.Context.DeleteObject(this.ObjDAL); } } else { Indico.DAL.Gender obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.Gender obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.Gender SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.Gender properties Indico.DAL.Gender obj = new Indico.DAL.Gender(); if (this.ID > 0) { obj = context.Gender.FirstOrDefault <Gender>(o => o.ID == this.ID); } obj.Name = this.Name; if (_hSCodesWhereThisIsGenderLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.HSCodeBO.ToEntityList(this.HSCodesWhereThisIsGender, context), obj.HSCodesWhereThisIsGender); } if (_patternsWhereThisIsGenderLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.PatternBO.ToEntityList(this.PatternsWhereThisIsGender, context), obj.PatternsWhereThisIsGender); } this._doNotUpdateDALObject = false; return(obj); }
/// <summary> /// Creates an instance of the GenderBO class using the supplied Indico.DAL.Gender. /// </summary> /// <param name="obj">a Indico.DAL.Gender whose properties will be used to initialise the GenderBO</param> internal GenderBO(Indico.DAL.Gender obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.Gender this.ID = obj.ID; this.Name = obj.Name; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToGender(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.Gender obj = this.SetDAL(objContext.Context); objContext.Context.AddToGender(obj); objContext.SaveChanges(); objContext.Dispose(); } }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.Gender)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.Gender obj = (Indico.DAL.Gender)eObj; // set the Indico.BusinessObjects.GenderBO properties this.ID = obj.ID; this.Name = obj.Name; this._doNotUpdateDALObject = false; }