public HomeController(DapperDBContext context, IUserInfoService _iUserInfoService, AutoMapper.IMapper _modelMapper) { _context = context; iUserInfoService = _iUserInfoService; modelMapper = _modelMapper; }
public DemoService(DapperDBContext context, IDemoRepository _iDemoRepository, AutoMapper.IMapper _modelMapper) { _context = context; iDemoRepository = _iDemoRepository; modelMapper = _modelMapper; }
public IndexModel(DapperDBContext context, IUserInfoService _iUserInfoService, AutoMapper.IMapper _modelMapper) { _context = context; iUserInfoService = _iUserInfoService; modelMapper = _modelMapper; }
public UserInfoService(DapperDBContext context, IUserInfoRepository _iUserInfoRepository, AutoMapper.IMapper _modelMapper) { _context = context; iUserInfoRepository = _iUserInfoRepository; modelMapper = _modelMapper; }
//For PGSQL public List <T> GetData <T>(string sql, object obj, DapperDBContext _dbContext) { using (IDbConnection conn = new NpgsqlConnection(_dbContext.Connection)) { var data = conn.Query <T>(sql, obj, commandTimeout: 1800).ToList(); return(data); } }
private readonly IOptions <Infrastructure.Dtos.Config.AppSettings> appSettings; //配置文件数据 /// <summary> /// DemoController /// </summary> public TestController(DapperDBContext _context , IDemoService _iDemoService, AutoMapper.IMapper _modelMapper, IHostingEnvironment hostingEnv , IOptions <Infrastructure.Dtos.Config.AppSettings> _appSettings) { context = _context; iDemoService = _iDemoService; modelMapper = _modelMapper; this.Log = LogManager.GetLogger(Startup.Repository.Name, typeof(HomeController)); appSettings = _appSettings; }
/// <summary> /// HomeController /// </summary> public HomeController(DapperDBContext context, IUserInfoService _iUserInfoService, AutoMapper.IMapper _modelMapper, IHostingEnvironment hostingEnv, IConfiguration configuration , ITokenHelper _tokenHelper) { _context = context; iUserInfoService = _iUserInfoService; modelMapper = _modelMapper; _configuration = configuration; tokenHelper = _tokenHelper; this.Log = LogManager.GetLogger(Startup.Repository.Name, typeof(HomeController)); }
public void FixBatchInventory() { IDBContext db = new DapperDBContext("masterDB"); // 查询 异常批次数据 var sql = @"select p.id,p.`Code`,p.BarCode,s.StoreId,s.Quantity,t.Quantity as bqty,c.Quantity as hqty from storeinventory s left JOIN (select b.StoreId,b.ProductId,sum(b.Quantity) as Quantity from storeinventorybatch b group by b.StoreId,b.ProductId) t on s.StoreId = t.StoreId and s.ProductId = t.ProductId left join (select h.StoreId,h.ProductId,sum( h.ChangeQuantity) as Quantity from storeinventoryhistory h GROUP BY h.StoreId,h.ProductId ) c on s.StoreId = c.StoreId and s.ProductId = c.ProductId left join product p on p.id = s.ProductId where s.Quantity<>c.Quantity or c.Quantity<>t.Quantity or s.Quantity<>t.Quantity "; var waitFixProducts = db.Table.FindAll <FixProduct>(sql, null); foreach (var item in waitFixProducts) { if (item.Quantity <= 0) { //更新当前所有商品批次库存为0 if (item.Bqty > 0) { string sqlUpdate = "update storeinventorybatch set Quantity = 0 where StoreId=@StoreId and ProductId=@ProductId and Quantity>0"; db.Command.AddExecute(sqlUpdate, new { StoreId = item.StoreId, ProductId = item.Id }); } } else { // 把批次库存数修复成与总库存一致 var inventoryBatchs = db.Table.FindAll <StoreInventoryBatch>("select * from storeinventorybatch where storeId=@StoreId and productId = @ProductIds and Quantity>0", new { StoreId = item.StoreId, ProductIds = item.Id }).OrderBy(n => n.BatchNo).ToList(); if (item.Quantity < item.Bqty) { var updateList = MinusInventory(inventoryBatchs, item.Bqty - item.Quantity); if (updateList.Count > 0) { db.Update(updateList.ToArray()); } } else { } } } // db.SaveChange(); Assert.AreEqual(1, 1); }
public void TestTimespan_MySql() { var strConn = ConfigurationManager.ConnectionStrings["ebsdb"].ConnectionString; DapperDBContext db = new DapperDBContext("ebsdb"); var model = db.Table <temp_test>().FirstOrDefault(n => n.Id == 1); var version1 = model.RowVersion; model.Quantity += 100; db.Update(model); db.SaveChange(); var model2 = db.Table <temp_test>().FirstOrDefault(n => n.Id == 1); Assert.AreNotEqual(version1, model2.RowVersion); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddTransient <IBuildingRepositories, BuildingRepositories>() .AddTransient <IObjectRepositories, ObjectRepositories>() .AddTransient <IDataFieldRepositories, DataFieldRepositories>() .AddTransient <IReadingRepositories, ReadingRepositories>(); var connection = new DapperDBContext(Configuration.GetConnectionString("DatabaseITEST")); services.AddSingleton(connection) .Configure <ReadingConfig>(Configuration.GetSection("ReadingConfig")) .AddSingleton(r => r.GetRequiredService <IOptions <ReadingConfig> >().Value) .AddSingleton <IDocumentExecuter, DocumentExecuter>(); services.AddSingleton <RootQuery>() .AddSingleton <BuildingQuery>() .AddSingleton <DataFieldQuery>() .AddSingleton <ObjectQuery>() .AddSingleton <ReadingQuery>(); services.AddSingleton <ObjectType>() .AddSingleton <DataFieldType>() .AddSingleton <BuildingType>() .AddSingleton <ReadingType>() .AddSingleton <ReadingResponseType>(); services.AddSingleton <IDependencyResolver>(_ => new FuncDependencyResolver(_.GetRequiredService)) .AddSingleton <ISchema, S3ITESTSchema>(); services.AddControllers(); services.AddMvc(option => option.EnableEndpointRouting = false) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); }
public void Init() { _db = new DapperDBContext("dbtest"); }
public BuildingRepositories(DapperDBContext dbContext) { _dbContext = dbContext; }
public Test1Repository(DapperDBContext context) : base(context) { _context = context; }
public SysKeywordsRepository(DapperDBContext context) { _context = context; }
public MessageBoxRepository(DapperDBContext context) { _context = context; }
public SysRoleAlarmLevelRepository(DapperDBContext context) { _context = context; }
public BaseRepository(DapperDBContext context) { _context = context; }
public NurseReportRepository(DapperDBContext context) : base(context) { }
public UowProductRepository(DapperDBContext context) { _context = context; }
private readonly IOptions <Infrastructure.Dtos.Config.AppSettings> appSettings; //配置文件数据 public DemoRepository(DapperDBContext _context, IOptions <Infrastructure.Dtos.Config.AppSettings> _appSettings) : base(_context) { context = _context; appSettings = _appSettings; }
public DapperUnitOfWorkFactory(DapperDBContext context) { _context = context; }
public UserInfoRepository(IContext context) { _context = (DapperDBContext)context; }
public SysUserRoleRepository(DapperDBContext context) { _context = context; }
public BaseCurrencyRepository(DefaultEFDBContext context, DapperDBContext dapperCcontext) : base(context) { _context = context; _dapperContext = dapperCcontext; }
public UowProductsRepository(DapperDBContext context) { this._context = context; }
public PostRepository(DapperDBContext context) : base(context) { _context = context; }
public UserAddressRepository(IContext context) { _context = (DapperDBContext)context; }
public UowCategoryRepository(DapperDBContext context) { _context = context; }
public ObjectRepositories(DapperDBContext dbContext) { _dbContext = dbContext; }
public SysRoleMenuRepository(DapperDBContext context) { _context = context; }