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