【发布时间】:2020-02-27 15:00:51
【问题描述】:
我想获取所有过程代码,但在 coun() 工作正常时出现错误“方法 'all' 没有重载需要 0 个参数”
private static void Processor()
{
IUnitOfWorkManager _unitOfWorkManager = IocManager.Instance.Resolve<IUnitOfWorkManager>();
IDbPerTenantConnectionStringResolver _connectionStringResolver = IocManager.Instance.Resolve<IDbPerTenantConnectionStringResolver>(); ;
IDbContextResolver _dbContextResolver = IocManager.Instance.Resolve<IDbContextResolver>();
var srcConnectionString = "Server=NABIIL\\SQLEXPRESS; Database=db-qa; Trusted_Connection=True;"; //ConnectionStringHelper.GetConnectionString("Default");
var targetConnectionString = "Server=NABIIL\\SQLEXPRESS; Database=db-Migrated; Trusted_Connection=True;"; //ConnectionStringHelper.GetConnectionString("Target");
DbContext srcContext, targetContext;
Debugger.Break();
var procedureCode = "";
using (srcContext= _dbContextResolver.Resolve<DbContext>(srcConnectionString, null))
{
//var items = srcContext.Patients.Count();
procedureCode = srcContext.ProcedureCodes.All();
Debugger.Break();
//_unitOfWorkManager.Current.SaveChanges();
}
using (targetContext = _dbContextResolver.Resolve<DbContext>(targetConnectionString, null))
{
Debugger.Break();
//var items = targetContext.Patients.Count();
targetContext.Patients.add(procedureCode);
//_unitOfWorkManager.Current.SaveChanges();
}
}
【问题讨论】:
-
你认为只做
.All()应该完成什么?Count和All不做同样的事情,所以这样比较它们并没有什么用处。 -
All仅返回一个布尔值,指示列表中的所有元素是否满足条件。当你想返回所有元素时,只需使用procedureCode = srcContext.ProcedureCodes。 -
@HimBromBeere 感谢您在我使用时回复。我得到了异常“该函数评估所有要运行的线程”
-
@HimBromBeere 我的问题解决了
标签: c# asp.net asp.net-mvc abp