Updated Insert Data (markdown)

2881099
2023-12-14 19:46:43 +08:00
parent cf23e82fd1
commit 64660a3e5c

@@ -117,7 +117,13 @@ bulk insert test reference (10 fields)
> The test results are all based on the same operating system, and all are preheated.
## 4. Insert the specified columns
## 4. Dynamic tablename
```csharp
fsql.Insert(items).AsTable("Topic_201903").ExecuteAffrows();
```
## 5. Insert the specified columns
```csharp
var t3 = fsql.Insert(items).InsertColumns(a => a.Title).ExecuteAffrows();
@@ -133,7 +139,7 @@ var t4 = fsql.Insert(items).InsertColumns(a =>new { a.Title, a.Clicks }).Execute
//(@Clicks9, @Title9)
```
## 5. Ignore the specified columns
## 6. Ignore the specified columns
```csharp
var t5 = fsql.Insert(items).IgnoreColumns(a => a.CreateTime).ExecuteAffrows();
@@ -149,7 +155,7 @@ var t6 = fsql.Insert(items).IgnoreColumns(a => new { a.Title, a.CreateTime }).Ex
//(@Clicks5), (@Clicks6), (@Clicks7), (@Clicks8), (@Clicks9)
```
## 6. Column Insertion Priority
## 7. Column Insertion Priority
```csharp
All Columns < Specified columns (InsertColumns) < Ignored Columns (IgnoreColumns)
@@ -159,7 +165,7 @@ All Columns < Specified columns (InsertColumns) < Ignored Columns (IgnoreColumns
- Otherwise, when using `InsertColumns` and not using `IgnoreColumns`, only the specified columns are inserted into the database;
- Otherwise, in the case of using `IgnoreColumns`, only unspecified columns are inserted into the database.
## 7、Dictionary Insert
## 8、Dictionary Insert
```csharp
var dic = new Dictionary<string, object>();
@@ -169,7 +175,7 @@ dic.Add("name", "xxxx");
fsql.InsertDict(dic).AsTable("table1").ExecuteAffrows();
```
## 8. Import table data
## 9. Import table data
```csharp
int affrows = fsql.Select<Topic>()
@@ -189,7 +195,7 @@ limit 10
Note: Because `Clicks` and `CreateTime` are not selected, it'll use the value set by the target entity attribute `[Column(InsertValueSql = xx)]`, or the default value of `C#` of the target entity attribute.
## 9. `Insert Ignore Into` (MySql only)
## 10. `Insert Ignore Into` (MySql only)
```csharp
fsql.Insert<Topic>().MySqlIgnoreInto().AppendData(items).ExecuteAffrows();
@@ -198,11 +204,11 @@ fsql.Insert<Topic>().MySqlIgnoreInto().AppendData(items).ExecuteAffrows();
//(@Clicks5), (@Clicks6), (@Clicks7), (@Clicks8), (@Clicks9)
```
## 10. `On Duplicate Key Update` (MySql only)
## 11. `On Duplicate Key Update` (MySql only)
[More information...](Insert-or-Update#6-on-duplicate-key-update-mysql-only)
## 11. `On Conflict Do Update` (PostgreSQL only)
## 12. `On Conflict Do Update` (PostgreSQL only)
[More information...](Insert-or-Update#7-on-conflict-do-update-postgresql-only)