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.OrderDetailQty obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.OrderDetailQty obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.OrderDetailQty SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.OrderDetailQty properties Indico.DAL.OrderDetailQty obj = new Indico.DAL.OrderDetailQty(); if (this.ID > 0) { obj = context.OrderDetailQty.FirstOrDefault <OrderDetailQty>(o => o.ID == this.ID); } obj.Qty = this.Qty; if (this.OrderDetail > 0) { obj.OrderDetail = context.OrderDetail.FirstOrDefault(o => o.ID == this.OrderDetail); } if (this.Size > 0) { obj.Size = context.Size.FirstOrDefault(o => o.ID == this.Size); } 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.OrderDetailQty)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.OrderDetailQty obj = (Indico.DAL.OrderDetailQty)eObj; // set the Indico.BusinessObjects.OrderDetailQtyBO properties this.ID = obj.ID; this.Qty = obj.Qty; this.OrderDetail = (obj.OrderDetailReference.EntityKey != null && obj.OrderDetailReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.OrderDetailReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Size = (obj.SizeReference.EntityKey != null && obj.SizeReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.SizeReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToOrderDetailQty(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.OrderDetailQty obj = this.SetDAL(objContext.Context); objContext.Context.AddToOrderDetailQty(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the OrderDetailQtyBO class using the supplied Indico.DAL.OrderDetailQty. /// </summary> /// <param name="obj">a Indico.DAL.OrderDetailQty whose properties will be used to initialise the OrderDetailQtyBO</param> internal OrderDetailQtyBO(Indico.DAL.OrderDetailQty obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.OrderDetailQty this.ID = obj.ID; this.OrderDetail = (obj.OrderDetailReference.EntityKey != null && obj.OrderDetailReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.OrderDetailReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Qty = obj.Qty; this.Size = (obj.SizeReference.EntityKey != null && obj.SizeReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.SizeReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }