-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to apply the .ToListAsync();? #71
Comments
Yes, you are absolutely right. |
Hello, Niki! Could you please clarify: Shall I use it in the Service like this: _itemsRepository.All().ToListAsync(); ? Or leave it as a wrapper method in the repository and calling it like this? |
I suggest you using it like |
Ok, but if I put it like this, 2 problems arrise:
|
In asynchronous programming there is a very useful async method: ToListAsync();
However, it comes from EntityFramework. So basically if we use the template here and call .All(); method in the Service and after that call .ToListAsync() in the service - then we will create a dependency between the Service and EF.
Perhaps I should add a wrapper method for this in the generic repository like I have done it here:
Or maybe there is a better way? Let me know your thoughts!
https://github.com/MiBuena/ListGeneratorAsync/blob/19093c731337d7b1b2a91963e047873142f4d9de/ListGeneration.Data/Repositories/EfRepository.cs#L30
The text was updated successfully, but these errors were encountered: