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.MYOBCardFile obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.MYOBCardFile obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.MYOBCardFile SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.MYOBCardFile properties Indico.DAL.MYOBCardFile obj = new Indico.DAL.MYOBCardFile(); if (this.ID > 0) { obj = context.MYOBCardFile.FirstOrDefault <MYOBCardFile>(o => o.ID == this.ID); } obj.Description = this.Description; obj.Name = this.Name; if (_ordersWhereThisIsMYOBCardFileLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.OrderBO.ToEntityList(this.OrdersWhereThisIsMYOBCardFile, context), obj.OrdersWhereThisIsMYOBCardFile); } this._doNotUpdateDALObject = false; return(obj); }
/// <summary> /// Creates an instance of the MYOBCardFileBO class using the supplied Indico.DAL.MYOBCardFile. /// </summary> /// <param name="obj">a Indico.DAL.MYOBCardFile whose properties will be used to initialise the MYOBCardFileBO</param> internal MYOBCardFileBO(Indico.DAL.MYOBCardFile obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.MYOBCardFile this.ID = obj.ID; this.Description = obj.Description; this.Name = obj.Name; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToMYOBCardFile(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.MYOBCardFile obj = this.SetDAL(objContext.Context); objContext.Context.AddToMYOBCardFile(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.MYOBCardFile)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.MYOBCardFile obj = (Indico.DAL.MYOBCardFile)eObj; // set the Indico.BusinessObjects.MYOBCardFileBO properties this.ID = obj.ID; this.Description = obj.Description; this.Name = obj.Name; this._doNotUpdateDALObject = false; }