public Task <IEnumerable <Models.Test.Example> > MultiRepoDefaultGetAsync() { // 設定默認使用 SqlDbSession 的過濾條件 UnitOfWork.GetDefaultDbSession().SetDefaultFilter(sessions => sessions.First()); // 這邊所使用的 Repo 必須是 MultiSqlRepo 型別 var repo = UnitOfWork.Use <IExampleMultiRepo>(); var result = repo.DefaultGetAsync(); return(result); }
public async Task <ActionResult <bool> > Get() { var r = ServiceProvider.GetService <ITestRepo>(); var multi = UnitOfWork.CreateDbSession(); UnitOfWork.Use <ITestRepo>(multi); UnitOfWork.Use <IOldRepo>(multi.First()); await Task.CompletedTask; return(Ok(true)); }