|
4 | 4 | using EntityFrameworkCore.SqlServer.SimpleBulks.BulkUpdate; |
5 | 5 | using EntityFrameworkCore.SqlServer.SimpleBulks.Demo; |
6 | 6 | using EntityFrameworkCore.SqlServer.SimpleBulks.Demo.Entities; |
| 7 | +using EntityFrameworkCore.SqlServer.SimpleBulks.DirectDelete; |
| 8 | +using EntityFrameworkCore.SqlServer.SimpleBulks.DirectInsert; |
| 9 | +using EntityFrameworkCore.SqlServer.SimpleBulks.DirectUpdate; |
7 | 10 | using Microsoft.EntityFrameworkCore; |
8 | 11 | using System; |
9 | 12 | using System.Collections.Generic; |
@@ -81,6 +84,40 @@ await dbct.BulkInsertAsync(configurationEntries, |
81 | 84 | Console.WriteLine($"Updated: {mergeResult.UpdatedRows} row(s)"); |
82 | 85 | Console.WriteLine($"Inserted: {mergeResult.InsertedRows} row(s)"); |
83 | 86 | 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 | + }); |
84 | 121 | } |
85 | 122 |
|
86 | 123 | Console.WriteLine("Finished!"); |
|
0 commit comments