コード例 #1
0
 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.SportsCategory obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext             objContext = new IndicoContext();
         Indico.DAL.SportsCategory obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates an instance of the SportsCategoryBO class using the supplied Indico.DAL.SportsCategory.
        /// </summary>
        /// <param name="obj">a Indico.DAL.SportsCategory whose properties will be used to initialise the SportsCategoryBO</param>
        internal SportsCategoryBO(Indico.DAL.SportsCategory obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

            // set the properties from the Indico.DAL.SportsCategory
            this.ID = obj.ID;

            this.Description = obj.Description;
            this.Name        = obj.Name;

            this._doNotUpdateDALObject = false;
        }
コード例 #3
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToSportsCategory(this.ObjDAL);
     }
     else
     {
         IndicoContext             objContext = new IndicoContext();
         Indico.DAL.SportsCategory obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToSportsCategory(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
コード例 #4
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

            // Check the received type
            if (eObj.GetType() != typeof(Indico.DAL.SportsCategory))
            {
                throw new FormatException("Received wrong parameter type...");
            }

            Indico.DAL.SportsCategory obj = (Indico.DAL.SportsCategory)eObj;

            // set the Indico.BusinessObjects.SportsCategoryBO properties
            this.ID = obj.ID;

            this.Description = obj.Description;
            this.Name        = obj.Name;


            this._doNotUpdateDALObject = false;
        }
コード例 #5
0
        internal Indico.DAL.SportsCategory SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

            // set the Indico.DAL.SportsCategory properties
            Indico.DAL.SportsCategory obj = new Indico.DAL.SportsCategory();

            if (this.ID > 0)
            {
                obj = context.SportsCategory.FirstOrDefault <SportsCategory>(o => o.ID == this.ID);
            }

            obj.Description = this.Description;
            obj.Name        = this.Name;



            this._doNotUpdateDALObject = false;

            return(obj);
        }