Exemple #1
0
 public bool Update(TEntity entity)
 {
     _dbSet.AddOrUpdate(entity);
     return(_context.SaveChanges() > 0);
 }
Exemple #2
0
 private static void FixDistricts(ref DbSet<District> districtSet)
 {
     var district = new District
     {
         DistrictId = 1,
         Title = "Mladá Boleslav"
     };
     districtSet.AddOrUpdate(district);
 }
Exemple #3
0
 public virtual TEntity Update(TEntity entityToUpdate)
 {
     dbSet.AddOrUpdate(entityToUpdate);
     Save();
     return(entityToUpdate);
 }
Exemple #4
0
 public void Update(T entity)
 {
     objectSet.AddOrUpdate(entity);
     context.SaveChanges();
 }
Exemple #5
0
 public void AddOrUpdate(T entity)
 {
     _dbSet.AddOrUpdate(entity);
 }
Exemple #6
0
 public void InsertOrUpdate(TEntity T)
 {
     _dbSet.AddOrUpdate(T);
 }
Exemple #7
0
 public void Update(DalUserProfile entity) => DbSet.AddOrUpdate(Mapper.ToOrmUserProfile(entity));
Exemple #8
0
 protected override void AddOrUpdateEntity(TEntity entity)
 {
     _set.AddOrUpdate(entity);
 }
        /// <summary>
        /// 添加更新数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <param name="exp"></param>
        /// <param name="param"></param>
        void AddOrUpdate <T>(DbContext context, Expression <Func <T, object> > exp, T[] param) where T : class
        {
            DbSet <T> set = context.Set <T>();

            set.AddOrUpdate(exp, param);
        }
 public virtual void AddOrUpdate(TEntity entity)
 {
     DbSet.AddOrUpdate(entity);
 }
Exemple #11
0
 public virtual void Save(TEntity entity)
 {
     DbSet.AddOrUpdate(entity);
     Context.SaveChanges();
 }
 public static void AddOrUpdateIfNoneExists <T>(this DbSet <T> dbset, T[] entity, Expression <Func <T, object> > identifierExpression = null) where T : class
 {
     dbset.AddOrUpdate(identifierExpression, entity);
 }
Exemple #13
0
        protected override void Seed(EFDbContext context)
        {
            //if(context.Database.Exists())
            //{
            //    context.Database.CompatibleWithModel(false);
            //    return;
            //}
            //Console.WriteLine("context.Database.CreateIfNotExists() return = {0}", context.Database.CreateIfNotExists());
            //if (context.Database.CreateIfNotExists())
            //{

            //    return;
            //}

            #region ///// 创建初始化角色
            List <SysRole> roles = new List <SysRole>
            {
                new SysRole {
                    Name = "管理员"
                },
                new SysRole {
                    Name = "校长"
                },
                new SysRole {
                    Name = "副校长"
                },
                new SysRole {
                    Name = "主任"
                },
                new SysRole {
                    Name = "副主任"
                },
                new SysRole {
                    Name = "教师"
                },
                new SysRole {
                    Name = "教工"
                }
            };
            DbSet <SysRole> roleSet = context.Set <SysRole>();
            roleSet.AddOrUpdate(m => new { m.Name }, roles.ToArray());
            context.SaveChanges();
            #endregion
            #region //////创建初始化部门
            List <SysDepartment> departments = new List <SysDepartment>
            {
                new SysDepartment {
                    Name = "甘高"
                },
                new SysDepartment {
                    Name = "办公室"
                },
                new SysDepartment {
                    Name = "政教处"
                },
                new SysDepartment {
                    Name = "德育处"
                },
                new SysDepartment {
                    Name = "总务处"
                },
            };
            DbSet <SysDepartment> departmentSet = context.Set <SysDepartment>();
            departmentSet.AddOrUpdate(m => new { m.Name }, departments.ToArray());
            context.SaveChanges();
            #endregion
            #region //// 创建初始化用户
            List <SysUser> users = new List <SysUser>
            {
                new SysUser {
                    Name = "admin", Description = "系统管理", Nick = "管理员"
                },
                new SysUser {
                    Name = "fhd", Description = "系统设计者", Nick = "无所谓"
                },
                new SysUser {
                    Name = "yagqfhd", Description = "教师", Nick = "付东"
                },
                new SysUser {
                    Name = "schooladmin", Description = "学校管理员", Nick = "管理者"
                },
            };
            DbSet <SysUser> userSet = context.Set <SysUser>();
            userSet.AddOrUpdate(m => new { m.Name }, users.ToArray());
            context.SaveChanges();
            #endregion
        }
Exemple #14
0
 private static void FixPhoneNumberPrefixes(ref DbSet<PhoneNumberPrefix> phoneNumberPrefixSet)
 {
     var phoneNumberPrefixe = new PhoneNumberPrefix
     {
         PhoneNumberPrefixId = 1,
         Title = "CZ +420",
         MatchRegex = "^(00420|420).*$",
         ReplaceRegex = "^(00420|420)",
         ExportablePrefix = "00420"
     };
     phoneNumberPrefixSet.AddOrUpdate(phoneNumberPrefixe);
 }
Exemple #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity"></param>
 public void InsertOrEdit(TModel entity)
 {
     dbSet.AddOrUpdate(entity);
 }
 public void AddOrUpdate(TEntity entity)
 {
     Table.AddOrUpdate(entity);
     Save();
 }
Exemple #17
0
 public void Update(T entity)
 {
     _objectSet.AddOrUpdate(entity);
 }
Exemple #18
0
 public void Update(TEntity entity)
 {
     DbSet.AddOrUpdate(entity);
 }
Exemple #19
0
 public virtual void Update(T item)
 {
     Entities.AddOrUpdate(item);
 }
Exemple #20
0
 public void Update(TEntity entity)
 {
     set.AddOrUpdate(entity);
     //context.Entry(entity).State = EntityState.Modified;
     Save();
 }
Exemple #21
0
        protected override void Seed(EFDbContext context)
        {
            List <Role> roles = new List <Role>
            {
                new Role {
                    Name = "系统管理员", Description = "系统管理员,按级别进行分配管理权限。", RoleType = RoleType.Admin
                },
                new Role {
                    Name = "超级管理员", Description = "超级管理员,拥有整个系统的管理权限。", RoleType = RoleType.Admin
                },
                new Role {
                    Name = "系统用户", Description = "系统用户,按级别进行分配管理权限。", RoleType = RoleType.User
                },
                new Role {
                    Name = "普通会员", Description = "普通会员,按级别进行分配管理权限。", RoleType = RoleType.User
                },
                new Role {
                    Name = "高级会员", Description = "高级会员,按级别进行分配管理权限。", RoleType = RoleType.User
                }
            };
            DbSet <Role> roleSet = context.Set <Role>();

            roleSet.AddOrUpdate(m => new { m.Name }, roles.ToArray());
            context.SaveChanges();

            List <SystemUser> Users = new List <SystemUser>
            {
                new SystemUser {
                    UserName = "******", ContactNumber = "13986751153", Password = "******", Email = "*****@*****.**", NickName = "零零柒"
                },
                new SystemUser {
                    UserName = "******", ContactNumber = "13572232256", Password = "******", Email = "*****@*****.**", NickName = "零零柒"
                }
            };

            DbSet <SystemUser> SysUserSet = context.Set <SystemUser>();

            SysUserSet.AddOrUpdate(m => new { m.UserName }, Users.ToArray());
            context.SaveChanges();


            List <TaskType> TaskTypes = new List <TaskType>
            {
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "设计绘画", TaskParentTypeID = 0, TaskTypeLogo = "../Images/20160519748bzsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "软件开发", TaskParentTypeID = 0, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "写作翻译", TaskParentTypeID = 0, TaskTypeLogo = "../Images/20160519748bzsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "市场营销", TaskParentTypeID = 0, TaskTypeLogo = "../Images/20160519748sjkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "人力资源", TaskParentTypeID = 0, TaskTypeLogo = "../Images/20160519748wxkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "文体教育", TaskParentTypeID = 0, TaskTypeLogo = "../Images/20160519748sjkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "平面设计", TaskParentTypeID = 1, TaskTypeLogo = "../Images/20160519748bzsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "UI设计", TaskParentTypeID = 1, TaskTypeLogo = "../Images/20160519748wxsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "工业设计", TaskParentTypeID = 1, TaskTypeLogo = "../Images/20160519748wxsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "拍摄知错", TaskParentTypeID = 1, TaskTypeLogo = "../Images/20160519748wxsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "手绘插画", TaskParentTypeID = 1, TaskTypeLogo = "../Images/20160519748wxsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "PPT设计", TaskParentTypeID = 1, TaskTypeLogo = "../Images/20160519748wxsj.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "网站建设", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "网店装修", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "APP开发", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "微信开发", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "软件系统", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "产品测试", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "IOS开发", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "游戏开发", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "数据库", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "H5前端", TaskParentTypeID = 2, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "文稿撰写", TaskParentTypeID = 3, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "数据录入", TaskParentTypeID = 3, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "专业翻译", TaskParentTypeID = 3, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "专业起名", TaskParentTypeID = 3, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "活动策划", TaskParentTypeID = 3, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "品牌策划", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "微信运营", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "微博运营", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "线下推广", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "SEO优化", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "广告推广", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "实习兼职", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "人事服务", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "人才招聘", TaskParentTypeID = 4, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "家教辅导", TaskParentTypeID = 5, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "外语培训", TaskParentTypeID = 5, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
                new TaskType {
                    SystemUserID = 1, TaskTypeName = "考前培训", TaskParentTypeID = 5, TaskTypeLogo = "../Images/20160519748zdkf.png"
                },
            };
            DbSet <TaskType> TaskTypeSet = context.Set <TaskType>();

            TaskTypeSet.AddOrUpdate(m => new { m.TaskTypeName }, TaskTypes.ToArray());
            context.SaveChanges();
            List <ForumType> ForumTypes = new List <ForumType>
            {
                new ForumType {
                    SystemUserID = 1, ForumTypeName = ".net技术", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "编程语言", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "软件设计", ForumParentTypeID = 0, ForumTypeLogo = ""
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "WEB前端", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "企业信息化", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "手机开发", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "软件工程", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "数据库技术", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "操作系统", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "求职面试", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "书籍推荐", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "搞怪趣事", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
                new ForumType {
                    SystemUserID = 1, ForumTypeName = "生活黄页", ForumParentTypeID = 0, ForumTypeLogo = "1"
                },
            };
            DbSet <ForumType> ForumTypeSet = context.Set <ForumType>();

            ForumTypeSet.AddOrUpdate(m => new { m.ForumTypeName }, ForumTypes.ToArray());
            context.SaveChanges();
            List <FileType> FileTypes = new List <FileType>
            {
                new FileType {
                    SystemUserID = 1, FileTypeName = ".net技术", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "编程语言", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "软件设计", FileParentTypeID = 0, FileTypeLogo = ""
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "WEB前端", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "企业信息化", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "手机开发", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "软件工程", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "数据库技术", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "操作系统", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "求职面试", FileParentTypeID = 0, FileTypeLogo = "1"
                },
                new FileType {
                    SystemUserID = 1, FileTypeName = "书籍推荐", FileParentTypeID = 0, FileTypeLogo = "1"
                },
            };
            DbSet <FileType> FileTypeSet = context.Set <FileType>();

            FileTypeSet.AddOrUpdate(m => new { m.FileTypeName }, FileTypes.ToArray());
            context.SaveChanges();
        }
 public int Update(TEntity entity)
 {
     _table.AddOrUpdate(entity);
     return(this.save());
 }
 public void AddAll(List <T> entities)
 {
     entities.ForEach(e => _dbSet.AddOrUpdate(e));
     _db.SaveChanges();
     UpdateActualityInfo();
 }
 public void InsertCategoria(Categoria entity)
 {
     _set.AddOrUpdate(entity);
     Commit();
 }
Exemple #25
0
 public void Update(WordTranslation entity)
 {
     DbSet.AddOrUpdate(e => new { e.OriginalWordId, e.TranslationWordId }, entity);
 }
 public virtual async Task AddOrUpdateAsync(TEntity entity, CancellationToken cancellationToken = default)
 {
     entities.AddOrUpdate(entity);
     await SaveAsync(cancellationToken : cancellationToken);
 }
Exemple #27
0
 public void Update(TEntity entity)
 {
     set.AddOrUpdate(entity);
     Save();
 }
Exemple #28
0
 public TEntity Update(TEntity entity)
 {
     _objectSet.AddOrUpdate(entity);
     _dB.SaveChanges();
     return(entity);
 }
 public void Update(string rowid, TEntity entity)
 {
     _dbSet.AddOrUpdate(entity);
     _dbContext.SaveChanges();
 }
Exemple #30
0
        private static void FixMeetingTitleTypesAndMeetings(ref DbContext dbContext, ref DbSet<MeetingTitleType> meetingTitleTypeSet, ref DbSet<Meeting> meetingSet)
        {
            var meetingTitleType = meetingTitleTypeSet.FirstOrDefault(mtts => mtts.Title == "ST");
            if (meetingTitleType == null)
            {
                meetingTitleType = new MeetingTitleType
                {
                    MeetingType = MeetingType.SetkaniTymu,
                    Title = "ST"
                };
                meetingTitleTypeSet.AddOrUpdate(meetingTitleType);
            }
            else
            {
                meetingTitleType.MeetingType = MeetingType.SetkaniTymu;
            }

            dbContext.SaveChanges();

            // Nastavit defaultní název setkání týmu
            meetingTitleType = meetingTitleTypeSet.First(mtt => mtt.Title == "ST");
            Meeting[] meetings = meetingSet.Where(m => m.MeetingType == MeetingType.SetkaniTymu && !m.MeetingTitleTypeId.HasValue).ToArray();
            if (meetings.Length == 0)
                return;

            foreach (Meeting meeting in meetings)
            {
                meeting.MeetingTitleTypeId = meetingTitleType.MeetingTitleTypeId;
            }
        }
 /// <summary>
 /// Update a certain element
 /// </summary>
 /// <param name="entity"></param>
 public void Attach(T entity)
 {
     _objectSet.AddOrUpdate(entity);
 }
 public void Update(TEntity entity)
 {
     _entity?.AddOrUpdate(entity);
 }
Exemple #33
0
 public void Update(TEntity obj)
 {
     entidade.AddOrUpdate(obj);
 }