Skip to content

Commit d83467b

Browse files
committed
add support DyRepository.UseTransactionAttribute
1 parent d840e36 commit d83467b

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

src/SmartSql.DyRepository/EmitRepositoryBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ private static void EmitSetTransaction(ILGenerator ilGen, MethodInfo methodInfo)
432432
{
433433
ilGen.LoadLocalVar(0);
434434
ilGen.LoadInt32(useTransactionAttribute.Level.GetHashCode());
435+
ilGen.New(NullableType<IsolationLevel>.Ctor);
435436
ilGen.Callvirt(RequestContextType.Method.SetTransaction);
436437
}
437438
}

src/SmartSql/Reflection/TypeConstants/DataType.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Collections;
44
using System.Data;
5-
using System.Reflection;
65

76
namespace SmartSql.Reflection.TypeConstants
87
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Text;
6+
7+
namespace SmartSql.Reflection.TypeConstants
8+
{
9+
public static class NullableType<TTarget> where TTarget : struct
10+
{
11+
public static Type TargetType = typeof(TTarget);
12+
public static readonly Type Type = typeof(TTarget?);
13+
14+
public static readonly ConstructorInfo Ctor = Type.GetConstructor(new Type[] { TargetType });
15+
}
16+
}

src/SmartSql/Reflection/TypeConstants/RequestContextType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static class Method
2525
{
2626
public static readonly MethodInfo SetDataSourceChoice = AbstractType.GetMethod("set_DataSourceChoice");
2727
public static readonly MethodInfo SetCommandType = AbstractType.GetMethod("set_CommandType");
28-
public static readonly MethodInfo SetTransaction = AbstractType.GetMethod("SetTransaction");
28+
public static readonly MethodInfo SetTransaction = AbstractType.GetMethod("set_Transaction");
2929
public static readonly MethodInfo SetScope = AbstractType.GetMethod("set_Scope");
3030
public static readonly MethodInfo SetSqlId = AbstractType.GetMethod("set_SqlId");
3131
public static readonly MethodInfo SetRequest = AbstractType.GetMethod("SetRequest");

src/SmartSql/RequestContext.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ public ResultMap GetCurrentResultMap()
5454
MultipleResultMap.Results[ExecutionContext.DataReaderWrapper.ResultIndex]?.Map : ResultMap;
5555
}
5656

57-
public void SetTransaction(IsolationLevel isolationLevel)
58-
{
59-
Transaction = isolationLevel;
60-
}
61-
6257
public abstract void SetupParameters();
6358
public abstract void SetRequest(object requestObj);
6459
}

0 commit comments

Comments
 (0)