C
C#15mo 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
Angius15mo ago
2
Scottek utek
Scottek utekOP15mo ago
dbcontext wont update if I use n1?
Angius
Angius15mo 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 utekOP15mo ago
yes ok thx

Did you find this page helpful?