So im asking this question because I'm not sure which one of these options is the proper solution for staying async. I guess both will do the job, but still I want to be sure which one is the prefarable way:
Invoking method (stays the same)
public async Task GetEntry(int id)
{
var entity = await _repository.GetByIdAsync(id)
}
Option 1 : Repository Note: This option is not using the async modifier
public Task<MyEntity> GetByIdAsync(int id)
{
return Query().SingleOrDefaultAsync(e => e.Id == id);
}
public IQueryable<MyEntity> Query()
{
return _dbContext.Set<MyEntity>().AsQueryable();;
}
Option 2 : Repository (using await and the async modifier)
public async Task<MyEntity> GetByIdAsync(int id)
{
return await Query().SingleOrDefaultAsync(e => e.Id == id);
}
public IQueryable<MyEntity> Query()
{
return _dbContext.Set<MyEntity>().AsQueryable();;
}