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.CostSheetImages obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.CostSheetImages obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.CostSheetImages SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.CostSheetImages properties Indico.DAL.CostSheetImages obj = new Indico.DAL.CostSheetImages(); if (this.ID > 0) { obj = context.CostSheetImages.FirstOrDefault <CostSheetImages>(o => o.ID == this.ID); } obj.Extension = this.Extension; obj.Filename = this.Filename; obj.Size = this.Size; if (this.CostSheet > 0) { obj.CostSheet = context.CostSheet.FirstOrDefault(o => o.ID == this.CostSheet); } this._doNotUpdateDALObject = false; return(obj); }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.CostSheetImages)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.CostSheetImages obj = (Indico.DAL.CostSheetImages)eObj; // set the Indico.BusinessObjects.CostSheetImagesBO properties this.ID = obj.ID; this.Extension = obj.Extension; this.Filename = obj.Filename; this.Size = obj.Size; this.CostSheet = (obj.CostSheetReference.EntityKey != null && obj.CostSheetReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CostSheetReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToCostSheetImages(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.CostSheetImages obj = this.SetDAL(objContext.Context); objContext.Context.AddToCostSheetImages(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the CostSheetImagesBO class using the supplied Indico.DAL.CostSheetImages. /// </summary> /// <param name="obj">a Indico.DAL.CostSheetImages whose properties will be used to initialise the CostSheetImagesBO</param> internal CostSheetImagesBO(Indico.DAL.CostSheetImages obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.CostSheetImages this.ID = obj.ID; this.CostSheet = (obj.CostSheetReference.EntityKey != null && obj.CostSheetReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CostSheetReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Extension = obj.Extension; this.Filename = obj.Filename; this.Size = obj.Size; this._doNotUpdateDALObject = false; }