© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
Scott hrot

✅ 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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Entity framework
C#CC# / help
14mo ago
❔ Entity Framework
C#CC# / help
3y ago
❔ Entity Framework
C#CC# / help
4y ago
Entity Framework Entity Saving
C#CC# / help
11mo ago