mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- 增加 DynamicFilterCustom 参数 object sender;#1113
This commit is contained in:
parent
b49c487906
commit
7903fc3eff
@ -786,5 +786,14 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="globalDataFilter"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user