| | |
| | | "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertCustomerBatch(db, customerGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteCustomerBatch(db, customerGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, customerGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | "B")) // 批量禁用仓库 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertDepotBatch(db, |
| | | depotsGroup.Value)) // 批量插入仓库 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteDepotBatch(db, |
| | | depotsGroup.Value)) // 批量删除仓库 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, |
| | | depotsGroup.Value)) // 批量插入或更新仓库 |
| | |
| | | if (!UpdateItemStatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | "B")) // 批量禁用岗位 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertPositionBatch(db, |
| | | positionGroup.Value)) // 批量插入岗位 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeletePositionBatch(db, |
| | | positionGroup.Value)) // 批量删除岗位 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdatePositionBatch(db, |
| | | positionGroup.Value)) // 批量插入或更新岗位 |
| | |
| | | |
| | | //这里面写的代码不会给覆盖,如果要重新生成请删除 MesRohInDataManager.cs |
| | | |
| | | |
| | | #region 教学方法 |
| | | |
| | | /// <summary> |
| | | /// 仓储方法满足不了复杂业务需求,业务代码请在这里面定义方法 |
| | | /// </summary> |
| | | public void Study() |
| | | { |
| | | /*********查询*********/ |
| | | |
| | | var data1 = base.GetById(1); //根据ID查询 |
| | | var data2 = base.GetList(); //查询所有 |
| | | var data3 = base.GetList(it => 1 == 1); //根据条件查询 |
| | | //var data4 = base.GetSingle(it => 1 == 1);//根据条件查询一条,如果超过一条会报错 |
| | | |
| | | var p = new PageModel { PageIndex = 1, PageSize = 2 }; // 分页查询 |
| | | var data5 = base.GetPageList(it => 1 == 1, p); |
| | | Console.Write(p.TotalCount); //返回总数 |
| | | |
| | | var data6 = |
| | | base.GetPageList(it => 1 == 1, p, |
| | | it => SqlFunc.GetRandom()); // 分页查询加排序 |
| | | Console.Write(p.TotalCount); //返回总数 |
| | | |
| | | var conModels = new List<IConditionalModel>(); //组装条件查询作为条件实现 分页查询加排序 |
| | | conModels.Add(new ConditionalModel |
| | | { |
| | | FieldName = typeof(MesRohInData).GetProperties()[0].Name, |
| | | ConditionalType = ConditionalType.Equal, FieldValue = "1" |
| | | }); //id=1 |
| | | var data7 = base.GetPageList(conModels, p, it => SqlFunc.GetRandom()); |
| | | |
| | | AsQueryable().Where(x => 1 == 1) |
| | | .ToList(); //支持了转换成queryable,我们可以用queryable实现复杂功能 |
| | | |
| | | |
| | | /*********插入*********/ |
| | | var insertData = new MesRohInData(); //测试参数 |
| | | var insertArray = new[] { insertData }; |
| | | base.Insert(insertData); //插入 |
| | | base.InsertRange(insertArray); //批量插入 |
| | | var id = base.InsertReturnIdentity(insertData); //插入返回自增列 |
| | | AsInsertable(insertData).ExecuteCommand(); //我们可以转成 Insertable实现复杂插入 |
| | | |
| | | |
| | | /*********更新*********/ |
| | | var updateData = new MesRohInData(); //测试参数 |
| | | var updateArray = new[] { updateData }; //测试参数 |
| | | base.Update(updateData); //根据实体更新 |
| | | base.UpdateRange(updateArray); //批量更新 |
| | | //base.Update(it => new MesRohInData() { ClassName = "a", CreateTime = DateTime.Now }, it => it.id==1);// 只更新ClassName列和CreateTime列,其它列不更新,条件id=1 |
| | | AsUpdateable(updateData).ExecuteCommand(); //转成Updateable可以实现复杂的插入 |
| | | |
| | | |
| | | /*********删除*********/ |
| | | var deldata = new MesRohInData(); //测试参数 |
| | | base.Delete(deldata); //根据实体删除 |
| | | base.DeleteById(1); //根据主键删除 |
| | | base.DeleteById(new[] { 1, 2 }); //根据主键数组删除 |
| | | base.Delete(it => 1 == 2); //根据条件删除 |
| | | AsDeleteable().Where(it => 1 == 2) |
| | | .ExecuteCommand(); //转成Deleteable实现复杂的操作 |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | |
| | | "B")) // 批量禁用员工 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertStaffBatch(db, userList, |
| | | staffGroup.Value)) // 批量插入员工 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteStaffBatch(db, userList, |
| | | staffGroup.Value)) // 批量删除员工 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, userList, |
| | | staffGroup.Value)) // 批量插入或更新员工 |
| | |
| | | "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertSupplierBatch(db, supplierGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteSupplierBatch(db, supplierGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, supplierGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | if (!UpdateUnitStatusBatch(db, unitGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertUnitBatch(db, unitGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteUnitBatch(db, unitGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, unitGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | if (!UpdateOrganizetatusBatch(db, itemGroup.Value, "B")) |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteItemBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateBatch(db, itemGroup.Value)) |
| | | throw new NotImplementedException("同步失败"); |
| | |
| | | departmentGroup.Value, "B")) // 批量禁用部门 |
| | | throw new NotImplementedException("禁用失败"); |
| | | break; |
| | | case "2": |
| | | if (!InsertDepartmentBatch(db, |
| | | departmentGroup.Value)) // 批量插入部门 |
| | | throw new NotImplementedException("插入失败"); |
| | | break; |
| | | case "3": |
| | | if (!DeleteDepartmentBatch(db, |
| | | departmentGroup.Value)) // 批量删除部门 |
| | | throw new NotImplementedException("删除失败"); |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (!InsertOrUpdateDepartmentBatch(db, |
| | | departmentGroup.Value)) // 批量插入或更新部门 |