Skip to content

Commit

Permalink
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 12 additions & 3 deletions FreeSql/Extensions/EntityUtilExtensions.cs
Original file line number Diff line number Diff line change
@@ -43,9 +43,7 @@ public static string GetEntityKeyString(this IFreeSql orm, Type entityType, obje
for (var a = 0; a < pks.Length; a++) {
var isguid = pks[a].CsType.NullableTypeOrThis() == typeof(Guid);
Expression expthen = null;
if (isguid == false)
expthen = Expression.Assign(var3IsNull, Expression.Constant(true));
else {
if (isguid) {
expthen = Expression.Block(
new Expression[]{
Expression.Assign(Expression.MakeMemberAccess(var1Parm, _table.Properties[pks[a].CsName]), Expression.Call(MethodFreeUtilNewMongodbId)),
@@ -55,6 +53,17 @@ public static string GetEntityKeyString(this IFreeSql orm, Type entityType, obje
)
}.Where(c => c != null).ToArray()
);
} else if (pks.Length > 1 && pks[a].Attribute.IsIdentity) {
expthen = Expression.Block(
new Expression[]{
a > 0 ? Expression.Call(var2Sb, MethodStringBuilderAppend, Expression.Constant(splitString)) : null,
Expression.Call(var2Sb, MethodStringBuilderAppend,
Expression.Convert(Expression.MakeMemberAccess(var1Parm, _table.Properties[pks[a].CsName]), typeof(object))
)
}.Where(c => c != null).ToArray()
);
} else {
expthen = Expression.Assign(var3IsNull, Expression.Constant(true));
}
if (pks[a].Attribute.IsIdentity || isguid || pks[a].CsType == typeof(string) || pks[a].CsType.IsNullableType()) {
exps.Add(
2 changes: 1 addition & 1 deletion FreeSql/FreeSql.csproj
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.5.1.3</Version>
<Version>0.5.2</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>YeXiangQin</Authors>
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
2 changes: 2 additions & 0 deletions FreeSql/Internal/CommonProvider/AdoProvider/AdoProvider.cs
Original file line number Diff line number Diff line change
@@ -323,6 +323,8 @@ public object ExecuteScalar(DbConnection connection, DbTransaction transaction,
isclose = true;
}
cmd.Connection = connection;
if (transaction.Connection == connection)
cmd.Transaction = transaction;
}

if (IsTracePerformance) dt = DateTime.Now;

0 comments on commit e3c0f61

Please sign in to comment.