Skip to content
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

Sync-over-sync in EF6 code sample #3898

Closed
daonguyen120688 opened this issue Jun 17, 2022 · 1 comment · Fixed by #3899
Closed

Sync-over-sync in EF6 code sample #3898

daonguyen120688 opened this issue Jun 17, 2022 · 1 comment · Fixed by #3899
Assignees
Milestone

Comments

@daonguyen120688
Copy link

daonguyen120688 commented Jun 17, 2022

I have a concern about the below code block:

using (var context = new BlogContext())
{
    context.Database.Log = Console.Write;

    var blog = context.Blogs.First(b => b.Title == "One Unicorn");

    blog.Posts.First().Title = "Green Eggs and Ham";

    blog.Posts.Add(new Post { Title = "I do not like them!" });

    context.SaveChangesAsync().Wait();
}

Why do you provide an example that use .Wait()? I think it's a bad practice and can make developers misunderstand and go the wrong way while using asynchronous programming. In my opinion, you should provide a sample code that follows the best practice in order to make it more helpful to the reader.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

roji added a commit to roji/EntityFramework.Docs that referenced this issue Jun 17, 2022
@roji roji changed the title The code sample is not good Sync-over-sync in EF6 code sample Jun 17, 2022
@roji roji self-assigned this Jun 17, 2022
@roji roji added the area-ef6 label Jun 17, 2022
@roji roji added this to the 7.0.0 milestone Jun 17, 2022
@roji
Copy link
Member

roji commented Jun 17, 2022

Thanks, submitted #3899 to make this use simple, sync-only code.

roji added a commit to roji/EntityFramework.Docs that referenced this issue Jun 17, 2022
roji added a commit that referenced this issue Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants