Add insert example.
This commit is contained in:
parent
5a2a82b413
commit
963378f2e9
@ -13,7 +13,16 @@ using var context = new DeadBallZoneLeagueDbContext();
|
||||
// Rather than raise: "System.InvalidOperationException: Sequence contains no elements."
|
||||
// var firstCoach = await context.Coaches.FirstOrDefaultAsync();
|
||||
|
||||
async Task InsertCoach(string name)
|
||||
{
|
||||
var coach = new Coach { Name = name, CreatedDate = DateTime.UtcNow };
|
||||
await context.Coaches.AddAsync(coach);
|
||||
Console.WriteLine(context.ChangeTracker.DebugView.LongView);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
// If you have a list, you can use a batch insert, instead of a loop:
|
||||
// await context.Coaches.AddRangeAsync(coaches);
|
||||
}
|
||||
|
||||
async Task ListVSIQueryableCall()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user