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.PatternItemAttributeSub obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PatternItemAttributeSub obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.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.PatternItemAttributeSub)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.PatternItemAttributeSub obj = (Indico.DAL.PatternItemAttributeSub)eObj; // set the Indico.BusinessObjects.PatternItemAttributeSubBO properties this.ID = obj.ID; this.ItemAttribute = (obj.ItemAttributeReference.EntityKey != null && obj.ItemAttributeReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.ItemAttributeReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Pattern = (obj.PatternReference.EntityKey != null && obj.PatternReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PatternReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
internal Indico.DAL.PatternItemAttributeSub SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.PatternItemAttributeSub properties Indico.DAL.PatternItemAttributeSub obj = new Indico.DAL.PatternItemAttributeSub(); if (this.ID > 0) { obj = context.PatternItemAttributeSub.FirstOrDefault <PatternItemAttributeSub>(o => o.ID == this.ID); } if (this.ItemAttribute > 0) { obj.ItemAttribute = context.ItemAttribute.FirstOrDefault(o => o.ID == this.ItemAttribute); } if (this.Pattern > 0) { obj.Pattern = context.Pattern.FirstOrDefault(o => o.ID == this.Pattern); } this._doNotUpdateDALObject = false; return(obj); }
public void Add() { if (this.Context != null) { this.Context.Context.AddToPatternItemAttributeSub(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PatternItemAttributeSub obj = this.SetDAL(objContext.Context); objContext.Context.AddToPatternItemAttributeSub(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the PatternItemAttributeSubBO class using the supplied Indico.DAL.PatternItemAttributeSub. /// </summary> /// <param name="obj">a Indico.DAL.PatternItemAttributeSub whose properties will be used to initialise the PatternItemAttributeSubBO</param> internal PatternItemAttributeSubBO(Indico.DAL.PatternItemAttributeSub obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.PatternItemAttributeSub this.ID = obj.ID; this.ItemAttribute = (obj.ItemAttributeReference.EntityKey != null && obj.ItemAttributeReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.ItemAttributeReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Pattern = (obj.PatternReference.EntityKey != null && obj.PatternReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PatternReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
void PatternItemAttributeSubsWhereThisIsItemAttributeList_OnBeforeRemove(object sender, EventArgs e) { Indico.DAL.PatternItemAttributeSub obj = null; if (this.Context != null) { if (((IndicoList <Indico.BusinessObjects.PatternItemAttributeSubBO>)sender).Count > 0) { obj = ((IndicoList <Indico.BusinessObjects.PatternItemAttributeSubBO>)sender)[((IndicoList <Indico.BusinessObjects.PatternItemAttributeSubBO>)sender).Count - 1].ObjDAL; this.ObjDAL.PatternItemAttributeSubsWhereThisIsItemAttribute.Remove(obj); } } else { IndicoContext objContext = new IndicoContext(); obj = ((IndicoList <Indico.BusinessObjects.PatternItemAttributeSubBO>)sender)[((IndicoList <Indico.BusinessObjects.PatternItemAttributeSubBO>)sender).Count - 1].SetDAL(objContext.Context); this.ObjDAL.PatternItemAttributeSubsWhereThisIsItemAttribute.Remove(obj); objContext.SaveChanges(); objContext.Dispose(); } }