C
C#13mo ago
Scottek utek

✅ entity framework return all objects

Hello, If I use entity framework and I want to get all objects in my repository, what should I do? 1:
private IEnumerable<TrainName> GetTrainNames()
{
return _dbStorage.TrainNames;
}
private IEnumerable<TrainName> GetTrainNames()
{
return _dbStorage.TrainNames;
}
2:
private async Task<IEnumerable<TrainName>> GetTrainNames()
{
return await _dbStorage.TrainNames.ToListAsync();
}
private async Task<IEnumerable<TrainName>> GetTrainNames()
{
return await _dbStorage.TrainNames.ToListAsync();
}
Or something else?
4 Replies
Angius
Angius13mo ago
2
Scottek utek
Scottek utekOP13mo ago
dbcontext wont update if I use n1?
Angius
Angius13mo ago
It won't update in either case, you're not updating anything But in the first case, the DbSet will not be pupulated If that's what you meant
Scottek utek
Scottek utekOP13mo ago
yes ok thx
Want results from more Discord servers?
Add your server