当前位置: 首页>>代码示例>>C#>>正文


C# ChooseDishesEntities.Entry方法代码示例

本文整理汇总了C#中IShow.ChooseDishes.Data.ChooseDishesEntities.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# ChooseDishesEntities.Entry方法的具体用法?C# ChooseDishesEntities.Entry怎么用?C# ChooseDishesEntities.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IShow.ChooseDishes.Data.ChooseDishesEntities的用法示例。


在下文中一共展示了ChooseDishesEntities.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: editByLocation

        //0修改失败,-1修改重复
        public int editByLocation(Location local)
        {
            int flag = 0;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {

                //查询编码是否存在
                var type = entities.Location.SingleOrDefault(bt => bt.Code == local.Code && bt.Deleted == 0 && bt.LocationId != local.LocationId);
                if (type == null)
                {
                    DbEntityEntry<Location> entry = entities.Entry<Location>(local);
                    //设置操作类型
                    entry.State = System.Data.Entity.EntityState.Unchanged;
                    //设置属性是否参与修改 ,设置为false则无法更新数据
                    entry.Property("Code").IsModified = true;
                    entry.Property("Name").IsModified = true;
                    entry.Property("UpdateBy").IsModified = true;
                    entry.Property("UpdateDatetime").IsModified = true;
                    try
                    {
                        //关闭实体验证,不关闭验证需要整个对象全部传值
                        entities.Configuration.ValidateOnSaveEnabled = false;
                        //操作数据库
                        flag = entities.SaveChanges();
                        entities.Configuration.ValidateOnSaveEnabled = true;
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }
                }
                else
                {
                    flag = -1;
                }
            }
            return flag;
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:39,代码来源:ChooseDishesDataService.cs

示例2: delDishDao

 //删除道菜
 public int delDishDao(DishDao dishDao)
 {
     int flag = 0;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         //直接修改的方式
         DbEntityEntry<DishDao> entry = entities.Entry<DishDao>(dishDao);
         entry.State = System.Data.Entity.EntityState.Unchanged;
         //设置修改状态为ture 否则数据库不会更新
         entry.Property("UpdateBy").IsModified = true;
         entry.Property("Deleted").IsModified = true;
         entry.Property("UpdateDatetime").IsModified = true;
         try
         {
             //关闭实体验证,不关闭验证需要整个对象全部传值
             entities.Configuration.ValidateOnSaveEnabled = false;
             flag = entities.SaveChanges();
             entities.Configuration.ValidateOnSaveEnabled = true;
         }
         catch (Exception ex)
         {
             ex.ToString();
         }
     }
     return flag;
 }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:27,代码来源:ChooseDishesDataService.cs

示例3: editByBearing

 //0修改失败,-1修改重复
 public int editByBearing(Bearing bearing)
 {
     int flag = 0;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         var type = entities.Bearing.SingleOrDefault(bt => bt.Code == bearing.Code && bt.Deleted == 0 && bt.BearingId != bearing.BearingId);
         if (type == null)
         {
             //实体绑定model
             DbEntityEntry<Bearing> entry = entities.Entry<Bearing>(bearing);
             //设置操作类型
             entry.State = System.Data.Entity.EntityState.Unchanged;
             //设置修改状态为ture 否则数据库不会更新
             entry.Property("Code").IsModified = true;
             entry.Property("Name").IsModified = true;
             entry.Property("Status").IsModified = true;
             entry.Property("UpdateBy").IsModified = true;
             entry.Property("UpdateDatetime").IsModified = true;
             try
             {
                 //关闭实体验证,不关闭验证需要整个对象全部传值
                 entities.Configuration.ValidateOnSaveEnabled = false;
                 flag = entities.SaveChanges();
                 entities.Configuration.ValidateOnSaveEnabled = true;
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
         }
         else
         {
             flag = -1;
         }
     }
     return flag;
 }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:38,代码来源:ChooseDishesDataService.cs

示例4: delByLocation

        public int delByLocation(Location location)
        {
            int flag = 0;
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {

                DbEntityEntry<Location> entry = entities.Entry<Location>(location);
                //设置操作类型
                entry.State = System.Data.Entity.EntityState.Unchanged;
                //设置属性是否参与修改 ,设置为false则无法更新数据
                entry.Property("Deleted").IsModified = true;
                entry.Property("UpdateBy").IsModified = true;
                entry.Property("UpdateDatetime").IsModified = true;
                try
                {
                    //关闭实体验证,不关闭验证需要整个对象全部传值
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    flag = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
            return flag;
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:27,代码来源:ChooseDishesDataService.cs

示例5: DeleteMarketTypeById

	    public bool DeleteMarketTypeById(int id) {
            if (id < 0)
            {
                return false;
            }
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    MarketType booktype = new MarketType()
                    {
                        Id = id,
                    };
                    DbEntityEntry<MarketType> entry = entities.Entry<MarketType>(booktype);
                    entry.State = EntityState.Deleted;
                    entities.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }

            }
	    }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:26,代码来源:MarketTypeDataService.cs

示例6: DeleteProgram

 //删除折扣方案
 public bool DeleteProgram(int typeId)
 {
     bool flag = true;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         Expression<Func<DiscountProgram, bool>> checkCourse = Program => Program.DiscountId == typeId && Program.Deleted == 0;
         //先查询 后修改
         List<DiscountProgram> type = entities.DiscountProgram.Where(checkCourse).ToList();
         if (type != null && type.Count > 0)
         {
             foreach (var t in type)
             {
                 t.UpdateBy = SubjectUtils.GetAuthenticationId();
                 t.UpdateDatetime = DateTime.Now;
                 t.Deleted = 1;
                 //直接修改的方式
                 DbEntityEntry<DiscountProgram> entry = entities.Entry<DiscountProgram>(t);
                 entry.State = System.Data.Entity.EntityState.Modified;
                 //设置修改状态为ture 否则数据库不会更新
                 entry.Property("UpdateBy").IsModified = true;
                 entry.Property("Deleted").IsModified = true;
                 entry.Property("UpdateDatetime").IsModified = true;
                 try
                 {
                     //关闭实体验证,不关闭验证需要整个对象全部传值
                     entities.Configuration.ValidateOnSaveEnabled = false;
                     var result = entities.SaveChanges();
                     entities.Configuration.ValidateOnSaveEnabled = true;
                     if (result <= 0)
                     {
                         return false;
                     }
                 }
                 catch (Exception ex)
                 {
                     ex.ToString();
                 }
             }
         }
         return flag;
     }
 }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:43,代码来源:DiscountDataService+.cs

示例7: DeleteType

 public bool DeleteType(int typeId)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         DishType type = new DishType();
         type.DishTypeId = typeId;
         type.Deleted = 1;
         DbEntityEntry<DishType> entry = entities.Entry<DishType>(type);
         entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
         entry.Property("Deleted").IsModified = true;
         entry.Property("DishTypeId").IsModified = false;
         entities.Configuration.ValidateOnSaveEnabled = false;
         var result = entities.SaveChanges();
         entities.Configuration.ValidateOnSaveEnabled = true;
         if (result == 1)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:24,代码来源:DishService.cs

示例8: Deleted

        /**根据指定编码删除对应做法*/
        public bool Deleted(int id)
        {
            if (id < 0)
            {
                return false;
            }
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    DischesWay booktype = new DischesWay()
                    {
                        DischesWayId = id,
                    };
                    DbEntityEntry<DischesWay> entry = entities.Entry<DischesWay>(booktype);
                    entry.State = EntityState.Deleted;
                    entities.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }

            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:28,代码来源:DishesWayDataService.cs

示例9: DeletedTakeoutOrder

        //删除外卖单

        public bool DeletedTakeoutOrder(int id)
        {
            if (id < 0)
            {
                return false;
            }
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                try
                {
                    TakeoutOrder booktype = new TakeoutOrder()
                    {
                        TakeoutId = id,
                    };
                    DbEntityEntry<TakeoutOrder> entry = entities.Entry<TakeoutOrder>(booktype);
                    entry.State = EntityState.Deleted;
                    entities.SaveChanges();
                    return true;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }

            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:29,代码来源:TakeoutOrderDataService.cs

示例10: DeleteTable

        /**删除餐桌,逻辑删除**/
        public bool DeleteTable(int tableId)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    IShow.ChooseDishes.Data.Table table = new IShow.ChooseDishes.Data.Table();
                    table.TableId = tableId;
                    DbEntityEntry<IShow.ChooseDishes.Data.Table> entry = entities.Entry<IShow.ChooseDishes.Data.Table>(table);
                    entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                    entry.Property("Deleted").IsModified = true;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                    if (result == 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:31,代码来源:TableService.cs

示例11: UpdateTable

        public bool UpdateTable(IShow.ChooseDishes.Data.Table table)
        {
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                DbEntityEntry<IShow.ChooseDishes.Data.Table> entry = entities.Entry<IShow.ChooseDishes.Data.Table>(table);

                entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                entry.Property("Name").IsModified = true;
                entry.Property("Seat").IsModified = true;
                entry.Property("TableTypeId").IsModified = true;
                entry.Property("LocationId").IsModified = true;
                entry.Property("Status").IsModified = true;

                //TODO 是否已经启用,已启用则不能删除
                entry.Property("TableId").IsModified = false;

                try
                {
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;

                    if (result == 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    return false;
                }
            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:38,代码来源:TableService.cs

示例12: DeleteTableTypeDetail

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="detailId"></param>
        /// <returns></returns>
        public bool DeleteTableTypeDetail(int detailId)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    TableTypeDetail detail = new TableTypeDetail();
                    detail.TableTypeDetailId = detailId;
                    detail.Deleted = 1;
                    DbEntityEntry<IShow.ChooseDishes.Data.TableTypeDetail> entry = entities.Entry<IShow.ChooseDishes.Data.TableTypeDetail>(detail);
                    entry.State = System.Data.Entity.EntityState.Unchanged;
                    entry.Property("Deleted").IsModified = true;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    if (result == 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:36,代码来源:TableService.cs

示例13: UpdateTableTypeDetail

        /// <summary>
        /// 修改服务费低消设置
        /// </summary>
        /// <param name="detail">服务费设置详细</param>
        /// <param name="serverFeeMode">服务费模式</param>
        /// <returns>成功则返回true,失败返回false</returns>
        public bool UpdateTableTypeDetail(TableTypeDetail detail)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    detail.UpdateBy = SubjectUtils.GetAuthenticationId();
                    detail.UpdateDatetime = DateTime.Now;
                    DbEntityEntry<IShow.ChooseDishes.Data.TableTypeDetail> entry = entities.Entry<IShow.ChooseDishes.Data.TableTypeDetail>(detail);
                    entry.State = System.Data.Entity.EntityState.Unchanged;
                    entry.Property("StartMoney").IsModified = true;
                    entry.Property("StartGetMoneyTime").IsModified = true;
                    entry.Property("StartUnit").IsModified = true;
                    entry.Property("StartDateTime").IsModified = true;
                    entry.Property("EndDateTime").IsModified = true;
                    entry.Property("OutMoney").IsModified = true;
                    entry.Property("OutTime").IsModified = true;
                    entry.Property("OutTimeFree").IsModified = true;
                    entry.Property("ServerfreeNax").IsModified = true;
                    entry.Property("ServerfreeAccountType").IsModified = true;
                    entry.Property("ServerfreeNum").IsModified = true;
                    entry.Property("Rate").IsModified = true;
                    entry.Property("ConsumerMode").IsModified = true;
                    entry.Property("ConsumerMoney").IsModified = true;
                    entry.Property("UpdateDatetime").IsModified = true;
                    entry.Property("UpdateBy").IsModified = true;

                    //entry.Property("TableTypeDetailId").IsModified = false;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    if (result == 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:53,代码来源:TableService.cs

示例14: DeleteTableType

        /**删除桌类,逻辑删除**/
        public void DeleteTableType(int typeId)
        {
            try
            {
                using (ChooseDishesEntities entities = new ChooseDishesEntities())
                {
                    //检查是否被餐桌关联 

                    List<IShow.ChooseDishes.Data.Table> tableList = LoadTableByTypeId(typeId);
                    if (tableList != null && tableList.Count > 0)
                    {
                        throw new ServiceException("该餐桌类别关联了餐桌,不能删除!");
                    }
                    TableType type = new TableType();
                    type.TableTypeId = typeId;
                    type.Deleted = 1;
                    DbEntityEntry<TableType> entry = entities.Entry<TableType>(type);
                    entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                    entry.Property("Deleted").IsModified = true;

                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                    if (result == 1)
                    {
                        throw new ServiceException("修改失败!");
                    }
                }
            }
            catch (Exception e)
            {
                throw new ServiceException(e.Message);
            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:35,代码来源:TableService.cs

示例15: UpdateTableType

        public void UpdateTableType(TableType type)
        {

            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                DbEntityEntry<TableType> entry = entities.Entry<TableType>(type);

                entry.State = System.Data.Entity.EntityState.Unchanged;//Modified
                entry.Property("Name").IsModified = true;
                entry.Property("PeopleMin").IsModified = true;
                entry.Property("PeopleMax").IsModified = true;
                entry.Property("PriceType").IsModified = true;
                entry.Property("ServerfreeModel").IsModified = true;
                entry.Property("ColorType").IsModified = true;
                entry.Property("UpdateBy").IsModified = true;
                entry.Property("UpdateDatetime").IsModified = true;
                entry.Property("LowConsCalcType").IsModified = true;
                entry.Property("ServerFeeCalcType").IsModified = true;
                entry.Property("CanDiscount").IsModified = true;
                entry.Property("InLowConsume").IsModified = true;
                try
                {
                    entities.Configuration.ValidateOnSaveEnabled = false;
                    int result = entities.SaveChanges();
                    entities.Configuration.ValidateOnSaveEnabled = true;
                }
                catch (Exception e)
                {
                    throw new ServiceException(e.Message);
                }
            }
        }
开发者ID:huangxuanheng,项目名称:ChooseDishes,代码行数:32,代码来源:TableService.cs


注:本文中的IShow.ChooseDishes.Data.ChooseDishesEntities.Entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。