diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml
index 4335acb5..d34b34ef 100644
--- a/FreeSql.DbContext/FreeSql.DbContext.xml
+++ b/FreeSql.DbContext/FreeSql.DbContext.xml
@@ -786,5 +786,14 @@
+
+
+ 批量注入 Repository,可以参考代码自行调整
+
+
+
+
+
+
diff --git a/FreeSql.Tests/FreeSql.Tests.Provider.Sqlite.Data/Sqlite/Curd/SqliteSelectTest.cs b/FreeSql.Tests/FreeSql.Tests.Provider.Sqlite.Data/Sqlite/Curd/SqliteSelectTest.cs
index ad048023..b40fe1fb 100644
--- a/FreeSql.Tests/FreeSql.Tests.Provider.Sqlite.Data/Sqlite/Curd/SqliteSelectTest.cs
+++ b/FreeSql.Tests/FreeSql.Tests.Provider.Sqlite.Data/Sqlite/Curd/SqliteSelectTest.cs
@@ -2546,7 +2546,7 @@ WHERE (((name,no) in (('testname01','testname01')) OR not((a.""no"") LIKE '%test
public class DynamicFilterMyCustom
{
[DynamicFilterCustom]
- public static string MyRawSql(string value) => value;
+ public static string MyRawSql(object sender, string value) => value;
public static string TupleIn(string value)
{
diff --git a/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs b/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs
index 81f463e9..c438ae01 100644
--- a/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs
+++ b/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs
@@ -2664,7 +2664,7 @@ WHERE ((not((a.""name"") LIKE '%testname01') OR not((a.""no"") LIKE '%testname01
""Value"" : ""testname01""
},
{
- ""Field"" : ""MyRawSql FreeSql.Tests.Sqlite.DynamicFilterMyCustom,FreeSql.Tests"",
+ ""Field"" : ""MyRawSql2 FreeSql.Tests.Sqlite.DynamicFilterMyCustom,FreeSql.Tests"",
""Operator"" : ""Custom"",
""Value"" : ""(id,status) in (('testname01','finished'))""
},
@@ -2689,7 +2689,10 @@ WHERE (((name,no) in (('testname01','testname01')) OR not((a.""no"") LIKE '%test
public class DynamicFilterMyCustom
{
[DynamicFilterCustom]
- public static string MyRawSql(string value) => value;
+ public static string MyRawSql(object sender, string value) => value;
+
+ [DynamicFilterCustom]
+ public static string MyRawSql2(string value) => value;
public static string TupleIn(string value)
{
diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml
index 3a83da5e..90d7f92e 100644
--- a/FreeSql/FreeSql.xml
+++ b/FreeSql/FreeSql.xml
@@ -4269,7 +4269,7 @@
public class DynamicFilterCustom
{
[DynamicFilterCustom]
- public static string RawSql(string value) => value;
+ public static string RawSql(object sender, string value) => value;
}
}
diff --git a/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs b/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs
index e47c22e3..2ed9ffa2 100644
--- a/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs
+++ b/FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs
@@ -656,9 +656,13 @@ namespace FreeSql.Internal.CommonProvider
var fiValue1Type = Type.GetType(fiValueCustomArray[1]);
if (fiValue1Type == null) throw new ArgumentException(CoreStrings.NotFound_Reflection(fiValueCustomArray[1]));
var fiValue0Method = fiValue1Type.GetMethod(fiValueCustomArray[0], new Type[] { typeof(string) });
+ if (fiValue0Method == null) fiValue0Method = fiValue1Type.GetMethod(fiValueCustomArray[0], new Type[] { typeof(object), typeof(string) });
if (fiValue0Method == null) throw new ArgumentException(CoreStrings.NotFound_Static_MethodName(fiValueCustomArray[0]));
if (MethodIsDynamicFilterCustomAttribute(fiValue0Method) == false) throw new ArgumentException(CoreStrings.Custom_StaticMethodName_NotSet_DynamicFilterCustom(fiValueCustomArray[0]));
- var fiValue0MethodReturn = fiValue0Method?.Invoke(null, new object[] { fi.Value?.ToString() })?.ToString();
+ var fiValue0MethodReturn = fiValue0Method?.Invoke(null, fiValue0Method.GetParameters()
+ .Select(a => a.ParameterType == typeof(object) ? (object)this :
+ (a.ParameterType == typeof(string) ? (object)(fi.Value?.ToString()) : (object)null))
+ .ToArray())?.ToString();
exp = Expression.Call(typeof(SqlExt).GetMethod("InternalRawSql", BindingFlags.NonPublic | BindingFlags.Static), Expression.Constant(fiValue0MethodReturn, typeof(string)));
break;
diff --git a/FreeSql/Internal/Model/DynamicFilterInfo.cs b/FreeSql/Internal/Model/DynamicFilterInfo.cs
index 7b025e76..201b9c6c 100644
--- a/FreeSql/Internal/Model/DynamicFilterInfo.cs
+++ b/FreeSql/Internal/Model/DynamicFilterInfo.cs
@@ -132,7 +132,7 @@ namespace FreeSql.Internal.Model
/// public class DynamicFilterCustom
/// {
/// [DynamicFilterCustom]
- /// public static string RawSql(string value) => value;
+ /// public static string RawSql(object sender, string value) => value;
/// }
/// }
///