Skip to content

Commit

Permalink
- 增加 InsertDict ExecuteIdentity 重载指定自增列;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Oct 31, 2023
1 parent f83331c commit 52bc16d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion FreeSql/Extensions/FreeSqlGlobalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -1069,7 +1070,13 @@ public InsertDictImpl CommandTimeout(int timeout)
}

public int ExecuteAffrows() => _insertProvider.ExecuteAffrows();
public long ExecuteIdentity() => _insertProvider.ExecuteIdentity();
public long ExecuteIdentity(string identityColumn = null)
{
if (_insertProvider._table.ColumnsByCs.TryGetValue(identityColumn, out var col) == false)
throw new Exception(CoreStrings.GetPrimarys_ParameterError_IsNotDictKey(identityColumn).Replace(nameof(ExecuteIdentity), ""));
col.Attribute.IsIdentity = true;
return _insertProvider.ExecuteIdentity();
}
public List<Dictionary<string, object>> ExecuteInserted() => _insertProvider.ExecuteInserted();

#if net40
Expand Down
2 changes: 1 addition & 1 deletion Providers/FreeSql.Provider.Xugu/XuguExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public override string ExpressionLambdaToSqlMemberAccessDateTime(MemberExpressio
{
case "Now": return _common.Now;
case "UtcNow": return _common.NowUtc;
case "Today": return "convert(char(10),getdate(),120)";
case "Today": return $"cast(date_format({_common.Now},'%Y-%m-%d') as datetime)";
case "MinValue": return "'1753/1/1 0:00:00'";
case "MaxValue": return "'9999/12/31 23:59:59'";
}
Expand Down

0 comments on commit 52bc16d

Please sign in to comment.