From fc9d0894b95369b61997802ba3b975dc3dda8f91 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Sun, 8 Mar 2020 13:27:17 +0800 Subject: [PATCH] update --- 添加.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/添加.md b/添加.md index a5c0cd2..1ae90af 100644 --- a/添加.md +++ b/添加.md @@ -30,6 +30,21 @@ var t1 = fsql.Insert(items.First()).ExecuteAffrows(); //VALUES(?Clicks0, ?Title0, ?CreateTime0) ``` +如果表有自增列,插入数据后应该要返回 id。 + +方法1:(原始) +```csharp +long id = fsql.Insert(blog).ExecuteIdentity(); +blog.Id = id; +``` + +方法2:(依赖 FreeSql.Repository) +```csharp +var repo = fsql.GetRepository(); +repo.Insert(blog); +``` +> 将插入后的自增值,填充给 blog.Id + ## 2、批量插入 ```csharp