- 增加 DynamicFilterCustom 参数 object sender;#1113

This commit is contained in:
2881099
2022-05-23 01:22:45 +08:00
parent b49c487906
commit 7903fc3eff
6 changed files with 22 additions and 6 deletions

View File

@ -4269,7 +4269,7 @@
public class DynamicFilterCustom<para></para>
{<para></para>
[DynamicFilterCustom]<para></para>
public static string RawSql(string value) => value;<para></para>
public static string RawSql(object sender, string value) => value;<para></para>
}<para></para>
}<para></para>
</summary>

View File

@ -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;

View File

@ -132,7 +132,7 @@ namespace FreeSql.Internal.Model
/// public class DynamicFilterCustom<para></para>
/// {<para></para>
/// [DynamicFilterCustom]<para></para>
/// public static string RawSql(string value) => value;<para></para>
/// public static string RawSql(object sender, string value) => value;<para></para>
/// }<para></para>
/// }<para></para>
/// </summary>