Skip to content

Commit e7bdb61

Browse files
committed
Direct Insert, Update, Delete Samples
1 parent 7daee00 commit e7bdb61

File tree

1 file changed

+37
-0
lines changed
  • src/EntityFrameworkCore.SqlServer.SimpleBulks.Demo

1 file changed

+37
-0
lines changed

src/EntityFrameworkCore.SqlServer.SimpleBulks.Demo/Program.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using EntityFrameworkCore.SqlServer.SimpleBulks.BulkUpdate;
55
using EntityFrameworkCore.SqlServer.SimpleBulks.Demo;
66
using EntityFrameworkCore.SqlServer.SimpleBulks.Demo.Entities;
7+
using EntityFrameworkCore.SqlServer.SimpleBulks.DirectDelete;
8+
using EntityFrameworkCore.SqlServer.SimpleBulks.DirectInsert;
9+
using EntityFrameworkCore.SqlServer.SimpleBulks.DirectUpdate;
710
using Microsoft.EntityFrameworkCore;
811
using System;
912
using System.Collections.Generic;
@@ -81,6 +84,40 @@ await dbct.BulkInsertAsync(configurationEntries,
8184
Console.WriteLine($"Updated: {mergeResult.UpdatedRows} row(s)");
8285
Console.WriteLine($"Inserted: {mergeResult.InsertedRows} row(s)");
8386
Console.WriteLine($"Affected: {mergeResult.AffectedRows} row(s)");
87+
88+
var configurationEntry = new ConfigurationEntry
89+
{
90+
Key = $"Key_DirectInsert",
91+
Value = $"Value_DirectInsert",
92+
CreatedDateTime = DateTimeOffset.Now,
93+
SeasonAsInt = Season.Autumn,
94+
SeasonAsString = Season.Autumn,
95+
};
96+
97+
dbct.DirectInsert(configurationEntry,
98+
opt =>
99+
{
100+
opt.LogTo = Console.WriteLine;
101+
});
102+
103+
configurationEntry.Key += "_Updated";
104+
configurationEntry.Value += "_Updated";
105+
configurationEntry.UpdatedDateTime = DateTimeOffset.Now;
106+
configurationEntry.SeasonAsInt = Season.Spring;
107+
configurationEntry.SeasonAsString = Season.Spring;
108+
109+
dbct.DirectUpdate(configurationEntry,
110+
x => new { x.Key, x.Value, x.UpdatedDateTime, x.SeasonAsInt, x.SeasonAsString },
111+
opt =>
112+
{
113+
opt.LogTo = Console.WriteLine;
114+
});
115+
116+
dbct.DirectDelete(configurationEntry,
117+
opt =>
118+
{
119+
opt.LogTo = Console.WriteLine;
120+
});
84121
}
85122

86123
Console.WriteLine("Finished!");

0 commit comments

Comments
 (0)