public static void SetDbContextConnection(VOLContext beefContext, string dbName) { if (!ConnectionPool.ContainsKey(dbName)) { throw new Exception("数据库连接名称错误"); } beefContext.Database.GetDbConnection().ConnectionString = ConnectionPool[dbName]; }
/// <summary> /// 获取实体的数据库连接 /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="defaultDbContext"></param> /// <returns></returns> public static void GetDbContextConnection <TEntity>(VOLContext defaultDbContext) { //string connstr= defaultDbContext.Database.GetDbConnection().ConnectionString; // if (connstr != ConnectionPool[DefaultConnName]) // { // defaultDbContext.Database.GetDbConnection().ConnectionString = ConnectionPool[DefaultConnName]; // }; }
public static VOLContext GetEFDbContext(string dbName) { VOLContext beefContext = Utilities.HttpContext.Current.RequestServices.GetService(typeof(VOLContext)) as VOLContext; if (dbName != null) { if (!ConnectionPool.ContainsKey(dbName)) { throw new Exception("数据库连接名称错误"); } beefContext.Database.GetDbConnection().ConnectionString = ConnectionPool[dbName]; } return(beefContext); }
public async Task <IViewComponentResult> InvokeAsync(string dropDownIds) { if (string.IsNullOrEmpty(dropDownIds)) { return(null); } string[] dicNos = dropDownIds.Split(','); StringBuilder stringBuilder = new StringBuilder(); VOLContext context = DBServerProvider.GetEFDbContext(); var dicData = await(from d in context.Set <Sys_Dictionary>() join list in context.Set <Sys_DictionaryList>() on d.Dic_ID equals list.Dic_ID into t from list in t.DefaultIfEmpty() where dicNos.Contains(d.DicNo) select new { list.DicValue, list.DicName, d.Config, d.DbSql, list.OrderNo, d.DicNo }).ToListAsync(); foreach (var item in dicData.GroupBy(x => x.DicNo)) { stringBuilder.AppendLine($" var optionConfig{item.Key} = {item.Select(x => x.Config).FirstOrDefault()}"); string dbSql = item.Select(s => s.DbSql).FirstOrDefault(); stringBuilder.AppendLine($@" var dataSource{item.Key} = { (!string.IsNullOrEmpty(dbSql) ? DBServerProvider.GetSqlDapper().QueryList<object>(dbSql, null).Serialize() : item.OrderByDescending(o => o.OrderNo). Select(s => new { s.DicName, s.DicValue }).ToList() .Serialize()) }.convertToValueText(optionConfig{item.Key})"); stringBuilder.AppendLine($" optionConfig{item.Key}.data = dataSource{item.Key};"); } ViewBag.Dic = stringBuilder.ToString(); return(View("~/Views/Shared/Dictionary.cshtml")); }
public Hiiops_Shop_User_GroupRepository(VOLContext dbContext) : base(dbContext) { }
public vProvinceCityRepository(VOLContext dbContext) : base(dbContext) { }
public Wms_ProductCatalogRepository(VOLContext dbContext) : base(dbContext) { }
public Hiiops_Shop_Store_Product_AttrRepository(VOLContext dbContext) : base(dbContext) { }
public PartsRepository(VOLContext dbContext) : base(dbContext) { }
public BaseService(VOLContext dbContext) { Response = new WebResponseContent(true); this.DefaultDbContext = dbContext ?? throw new Exception("dbContext未实例化。"); }
public RepositoryBase(VOLContext dbContext) { this.DefaultDbContext = dbContext ?? throw new Exception("dbContext未实例化。"); }
public Sys_TableInfoRepository(VOLContext dbContext) : base(dbContext) { }
public App_PublicQuestionRepository(VOLContext dbContext) : base(dbContext) { }
public Sys_RoleRepository(VOLContext dbContext) : base(dbContext) { }
public ProductRepository(VOLContext dbContext) : base(dbContext) { }
public NewsPraiseRepository(VOLContext dbContext) : base(dbContext) { }
public Sys_LogRepository(VOLContext dbContext) : base(dbContext) { }
public Sys_DictionaryListRepository(VOLContext dbContext) : base(dbContext) { }
public App_TransactionAvgPriceRepository(VOLContext dbContext) : base(dbContext) { }
public App_ExpertQuestionRepository(VOLContext dbContext) : base(dbContext) { }
public vApp_QuestionReplyMeRepository(VOLContext dbContext) : base(dbContext) { }
public Sys_UserRepository(VOLContext dbContext) : base(dbContext) { }
public SellOrderRepository(VOLContext dbContext) : base(dbContext) { }
public FormCollectionObjectRepository(VOLContext dbContext) : base(dbContext) { }
public NewsTagRepository(VOLContext dbContext) : base(dbContext) { }
public Hiiops_Shop_Store_ServiceRepository(VOLContext dbContext) : base(dbContext) { }
public vSys_DictionaryRepository(VOLContext dbContext) : base(dbContext) { }
public Sys_MenuRepository(VOLContext dbContext) : base(dbContext) { }
public GoodsRepository(VOLContext dbContext) : base(dbContext) { }
public Hiiops_Shop_Store_Coupon_Issue_UserRepository(VOLContext dbContext) : base(dbContext) { }