mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-26 13:43:10 +08:00
-
This commit is contained in:
@@ -23,6 +23,7 @@ namespace OrmTest.UnitTest
|
||||
{
|
||||
|
||||
//Native methods
|
||||
ExtendContainsArray();
|
||||
ConvetToString();
|
||||
ExtendToString();
|
||||
ExtendSubstring();
|
||||
@@ -416,6 +417,16 @@ namespace OrmTest.UnitTest
|
||||
}, "Contains error");
|
||||
}
|
||||
|
||||
private void ExtendContainsArray() {
|
||||
string[] array = new string[] { "1", "2" };
|
||||
Expression<Func<Student, bool>> exp = it => array.Contains(it.Name);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
var pars = expContext.Parameters;
|
||||
base.Check(value, null, " ([Name] IN ('1','2')) ", null, "Contains2 error");
|
||||
}
|
||||
|
||||
private void ContainsArray()
|
||||
{
|
||||
string[] array = new string[] { "1", "2" };
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace SqlSugar
|
||||
var isLeft = parameter.IsLeft;
|
||||
string methodName = express.Method.Name;
|
||||
var isValidNativeMethod = MethodMapping.ContainsKey(methodName)&&express.Method.DeclaringType.Namespace==("System");
|
||||
if (!isValidNativeMethod&&express.Method.DeclaringType.Namespace== "System.Linq"&&methodName=="Contains") {
|
||||
methodName = "ContainsArray";
|
||||
isValidNativeMethod = true;
|
||||
}
|
||||
if (isValidNativeMethod)
|
||||
{
|
||||
NativeExtensionMethod(parameter, express, isLeft, MethodMapping[methodName]);
|
||||
@@ -240,6 +244,7 @@ namespace SqlSugar
|
||||
{ "Length","Length"},
|
||||
{ "Replace","Replace"},
|
||||
{ "Contains","Contains"},
|
||||
{ "ContainsArray","ContainsArray"},
|
||||
{ "EndsWith","EndsWith"},
|
||||
{ "StartsWith","StartsWith"},
|
||||
{ "HasValue","HasValue"},
|
||||
|
||||
Reference in New Issue
Block a user