我正在尝试以异步方式运行我的控制器操作。如何使用异步任务?或者如何以异步方式运行
// Db context
public class DeptContext : DbContext
{
public LagerContext(DbContextOptions<LagerContext> options)
: base(options)
{
Database.Migrate();
}
public DbSet<Department> Departments { get; set; }
public DbSet<Product> Products { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
// 这是我的接口 IDepRepository
Task<Department> GetDepartmentWithOrWithoutProducts(int deptId, bool includeProducts);
Run Code Online (Sandbox Code Playgroud)
// 还有我的 Repository 类 DepRepository
public class DepRepository : IDepRepository
{
private DeptContext db;
public DepRepository(DeptContext context)
{
db = context;
}
// I'am geting Department name with products or Without products
public async Task<Department> GetDepartmentWithOrWithoutProducts(int deptId, bool includeProducts) …Run Code Online (Sandbox Code Playgroud)