我的应用有2个数据库,Db1
(有表dbo.Student
)和Db2
(有表dbo.School
)。我创建了2个AppService来访问它们
当我尝试从两个数据中获取数据时,它仅使用与Db1
的连接(在当前上下文中找不到表dbo.School
)。那么如何才能同时从Db1和Db2获取数据
private readonly IStudentAppService _studentAppService;
private readonly ISchoolAppService _schoolAppService;
public BranchAccountController(IStudentAppService studentAppService,
ISchoolAppService schoolAppService)
{
_studentAppService = studentAppService;
_schoolAppService = schoolAppService;
}
public async Task<PartialViewResult> GetStudent(int? id)
{
//Repository 1 (Database 1)
var student = await _studentAppService.GetStudentForEdit(new NullableIdDto { Id = id });
//Repository 2 (Database 2)
var school = await _schoolAppService.GetSchoolList();
//bla bla
}
更新1: 我试着在学生面前上学,面对以下错误: 传入的事务与当前事务无关 连接。仅与当前连接关联的事务 可以使用。
答案 0 :(得分:2)
您必须 classifier = tf.estimator.DNNClassifier(feature_columns=feature_columns,
hidden_units=[10, 20, 10],
n_classes=3,
model_dir="/tmp/iris_model")
个单独的工作单元:
Begin