You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Try it (DataTable)](https://dotnetfiddle.net/UtvblA)
@@ -101,6 +91,7 @@ bulk.BulkInsert(customers);
101
91
[Try it (Entity)](https://dotnetfiddle.net/04NuC3)
102
92
103
93
### Insert and include/exclude properties
94
+
104
95
You want to insert your entities but only for specific properties.
105
96
106
97
-`ColumnInputExpression`: This option let you choose which properties to map.
@@ -121,23 +112,30 @@ bulk.BulkInsert(customers);
121
112
You want to insert entities but only those that don't already exist in the database.
122
113
123
114
-`InsertIfNotExists`: This option let you insert only entity that doesn't already exists.
124
-
-`PrimaryKeyExpression`: This option let you customize the key to use to check if the entity already exists or not.
115
+
-`PrimaryKeyExpression`: This option let you customize the key to use to check if the entity already exists or not. This option disable the Auto Mapping.
116
+
-`AutoMapKeyExpression`: This option let you customize the key with an expression and keep the Auto Mapping.
117
+
-`AutoMapKeyName`: This option let you customize the key by names and keep the Auto Mapping.
125
118
126
119
```csharp
127
120
bulk.InsertIfNotExists=true;
128
-
bulk.ColumnPrimaryKeyExpression=c=>c.Code;
121
+
bulk.AutoMapKeyExpression=c=>c.Code;
129
122
bulk.BulkInsert(customers);
130
123
```
131
-
[Try it (DataTable)](https://dotnetfiddle.net/waYK0E)
132
-
133
124
[Try it (Entity)](https://dotnetfiddle.net/DLMhLv)
134
125
126
+
```csharp
127
+
bulk.InsertIfNotExists=true;
128
+
bulk.AutoMapKeyName="Code";
129
+
bulk.BulkInsert(customers);
130
+
```
131
+
[Try it (DataTable)](https://dotnetfiddle.net/waYK0E)
0 commit comments