You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

615 lines
27 KiB

2 years ago
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Linq.Expressions;
  4. namespace SqlSugar
  5. {
  6. public class MethodCallExpressionResolve : BaseResolve
  7. {
  8. public MethodCallExpressionResolve(ExpressionParameter parameter) : base(parameter)
  9. {
  10. var express = base.Expression as MethodCallExpression;
  11. var isLeft = parameter.IsLeft;
  12. var methodName = express.Method.Name;
  13. var isValidNativeMethod = IsValidNativeMethod(express, methodName);
  14. List<MethodCallExpressionArgs> appendArgs = null;
  15. if (MethodTimeMapping.ContainsKey(methodName))
  16. {
  17. appendArgs = new List<MethodCallExpressionArgs>();
  18. var dateType = MethodTimeMapping[methodName];
  19. var paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
  20. appendArgs.Add(new MethodCallExpressionArgs { IsMember = false, MemberName = paramterName, MemberValue = dateType });
  21. this.Context.Parameters.Add(new SugarParameter(paramterName, dateType.ToString()));
  22. this.Context.ParameterIndex++;
  23. methodName = "DateAdd";
  24. isValidNativeMethod = true;
  25. }
  26. else if (methodName == "get_Item")
  27. {
  28. var paramterName = this.Context.SqlParameterKeyWord + ExpressionConst.Const + this.Context.ParameterIndex;
  29. this.Context.Parameters.Add(new SugarParameter(paramterName, ExpressionTool.DynamicInvoke(express)));
  30. this.Context.Result.Append(string.Format(" {0} ", paramterName));
  31. this.Context.ParameterIndex++;
  32. return;
  33. }
  34. else if (methodName == "NewGuid")
  35. {
  36. this.Context.Result.Append(this.Context.DbMehtods.GuidNew());
  37. return;
  38. }
  39. else if (IsSubMethod(express, methodName))
  40. {
  41. //Check.Exception(!(parameter.BaseExpression is BinaryExpression), "Current expressions are not supported");
  42. var subResolve = new SubResolve(express, this.Context, parameter.OppsiteExpression);
  43. var appendSql = subResolve.GetSql();
  44. if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle) || (parameter.BaseParameter != null && parameter.BaseParameter.CommonTempData != null && parameter.BaseParameter.CommonTempData.Equals(CommonTempDataType.Result)))
  45. {
  46. parameter.BaseParameter.CommonTempData = appendSql;
  47. }
  48. else
  49. {
  50. base.AppendValue(parameter, isLeft, appendSql);
  51. }
  52. return;
  53. }
  54. else if (IsIfElse(express, methodName))
  55. {
  56. var caseResole = new CaseWhenResolve(express, this.Context, parameter.OppsiteExpression);
  57. var appendSql = caseResole.GetSql();
  58. if (this.Context.ResolveType.IsIn(ResolveExpressType.SelectMultiple, ResolveExpressType.SelectSingle))
  59. {
  60. parameter.BaseParameter.CommonTempData = appendSql;
  61. }
  62. else
  63. {
  64. base.AppendValue(parameter, isLeft, appendSql);
  65. }
  66. return;
  67. }
  68. if (IsContainsArray(express, methodName, isValidNativeMethod))
  69. {
  70. methodName = "ContainsArray";
  71. isValidNativeMethod = true;
  72. }
  73. if (isValidNativeMethod)
  74. {
  75. NativeExtensionMethod(parameter, express, isLeft, MethodMapping[methodName], appendArgs);
  76. }
  77. else
  78. {
  79. SqlFuncMethod(parameter, express, isLeft);
  80. }
  81. }
  82. private bool IsValidNativeMethod(MethodCallExpression express, string methodName)
  83. {
  84. return MethodMapping.ContainsKey(methodName) && express.Method.DeclaringType.Namespace == ("System");
  85. }
  86. private bool IsExtMethod(string methodName)
  87. {
  88. if (this.Context.SqlFuncServices == null) return false;
  89. return this.Context.SqlFuncServices.Select(it => it.UniqueMethodName).Contains(methodName);
  90. }
  91. private bool IsIfElse(MethodCallExpression express, string methodName)
  92. {
  93. if (methodName == "End" && express.Object.Type == typeof(CaseWhen))
  94. return true;
  95. else
  96. return false;
  97. }
  98. private void SqlFuncMethod(ExpressionParameter parameter, MethodCallExpression express, bool? isLeft)
  99. {
  100. if (!CheckMethod(express))
  101. {
  102. CusMethod(parameter, express, isLeft);
  103. }
  104. else
  105. {
  106. var method = express.Method;
  107. var name = method.Name;
  108. var args = express.Arguments.Cast<Expression>().ToList();
  109. var model = new MethodCallExpressionModel
  110. {
  111. Args = new List<MethodCallExpressionArgs>()
  112. };
  113. switch (this.Context.ResolveType)
  114. {
  115. case ResolveExpressType.WhereSingle:
  116. case ResolveExpressType.WhereMultiple:
  117. Check.Exception(name == "GetSelfAndAutoFill", "SqlFunc.GetSelfAndAutoFill can only be used in Select.");
  118. Where(parameter, isLeft, name, args, model);
  119. break;
  120. case ResolveExpressType.SelectSingle:
  121. case ResolveExpressType.SelectMultiple:
  122. case ResolveExpressType.Update:
  123. Select(parameter, isLeft, name, args, model);
  124. break;
  125. case ResolveExpressType.FieldSingle:
  126. case ResolveExpressType.FieldMultiple:
  127. Field(parameter, isLeft, name, args, model);
  128. break;
  129. default:
  130. break;
  131. }
  132. }
  133. }
  134. private void CusMethod(ExpressionParameter parameter, MethodCallExpression express, bool? isLeft)
  135. {
  136. try
  137. {
  138. var constValue = ExpressionTool.DynamicInvoke(express);
  139. parameter.BaseParameter.CommonTempData = constValue;
  140. var parameterName = base.AppendParameter(constValue);
  141. if (parameter.BaseParameter.CommonTempData != null && parameter.BaseParameter.CommonTempData.Equals(CommonTempDataType.Result))
  142. {
  143. this.Context.Result.Append(parameterName);
  144. }
  145. else
  146. {
  147. base.AppendValue(parameter, isLeft, parameterName);
  148. }
  149. }
  150. catch
  151. {
  152. Check.Exception(true, string.Format(ErrorMessage.MethodError, express.Method.Name));
  153. }
  154. }
  155. private void NativeExtensionMethod(ExpressionParameter parameter, MethodCallExpression express, bool? isLeft, string name, List<MethodCallExpressionArgs> appendArgs = null)
  156. {
  157. var method = express.Method;
  158. var args = express.Arguments.Cast<Expression>().ToList();
  159. var model = new MethodCallExpressionModel
  160. {
  161. Args = new List<MethodCallExpressionArgs>()
  162. };
  163. switch (this.Context.ResolveType)
  164. {
  165. case ResolveExpressType.WhereSingle:
  166. case ResolveExpressType.WhereMultiple:
  167. if (express.Object != null)
  168. args.Insert(0, express.Object);
  169. Where(parameter, isLeft, name, args, model, appendArgs);
  170. break;
  171. case ResolveExpressType.SelectSingle:
  172. case ResolveExpressType.SelectMultiple:
  173. case ResolveExpressType.Update:
  174. if (express.Object != null)
  175. args.Insert(0, express.Object);
  176. Select(parameter, isLeft, name, args, model, appendArgs);
  177. break;
  178. case ResolveExpressType.FieldSingle:
  179. case ResolveExpressType.FieldMultiple:
  180. default:
  181. break;
  182. }
  183. }
  184. private void Field(ExpressionParameter parameter, bool? isLeft, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, List<MethodCallExpressionArgs> appendArgs = null)
  185. {
  186. if (this.Context.ResolveType == ResolveExpressType.FieldSingle)
  187. {
  188. this.Context.ResolveType = ResolveExpressType.WhereSingle;
  189. }
  190. else
  191. {
  192. this.Context.ResolveType = ResolveExpressType.WhereMultiple;
  193. }
  194. Where(parameter, isLeft, name, args, model);
  195. }
  196. private void Select(ExpressionParameter parameter, bool? isLeft, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, List<MethodCallExpressionArgs> appendArgs = null)
  197. {
  198. if (name == "GetSelfAndAutoFill")
  199. {
  200. var memberValue = (args.First() as MemberExpression).Expression.ToString();
  201. model.Args.Add(new MethodCallExpressionArgs { MemberValue = memberValue, IsMember = true, MemberName = memberValue });
  202. }
  203. else
  204. {
  205. foreach (var item in args)
  206. {
  207. AppendItem(parameter, name, args, model, item);
  208. }
  209. if (appendArgs != null)
  210. {
  211. model.Args.AddRange(appendArgs);
  212. }
  213. }
  214. if (parameter.BaseParameter.BaseParameter.BaseParameter == null)
  215. {
  216. this.Context.Result.Append(GetMdthodValue(name, model));
  217. }
  218. else
  219. {
  220. parameter.BaseParameter.CommonTempData = GetMdthodValue(name, model);
  221. }
  222. }
  223. private void Where(ExpressionParameter parameter, bool? isLeft, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, List<MethodCallExpressionArgs> appendArgs = null)
  224. {
  225. foreach (var item in args)
  226. {
  227. var expItem = item;
  228. if (item is UnaryExpression)
  229. {
  230. expItem = (item as UnaryExpression).Operand;
  231. }
  232. AppendItem(parameter, name, args, model, expItem);
  233. }
  234. if (appendArgs != null)
  235. {
  236. model.Args.AddRange(appendArgs);
  237. }
  238. var methodValue = GetMdthodValue(name, model);
  239. if (parameter.BaseExpression is BinaryExpression && parameter.OppsiteExpression.Type == UtilConstants.BoolType && name == "HasValue" && !(parameter.OppsiteExpression is BinaryExpression))
  240. {
  241. methodValue = this.Context.DbMehtods.CaseWhen(new List<KeyValuePair<string, string>> {
  242. new KeyValuePair<string, string>("IF",methodValue.ObjToString()),
  243. new KeyValuePair<string, string>("Return","1"),
  244. new KeyValuePair<string, string>("End","0")
  245. });
  246. }
  247. base.AppendValue(parameter, isLeft, methodValue);
  248. }
  249. private void AppendItem(ExpressionParameter parameter, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, Expression item)
  250. {
  251. var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
  252. var isConst = item is ConstantExpression;
  253. var isIIF = name == "IIF";
  254. var isIFFBoolMember = isIIF && (item is MemberExpression) && (item as MemberExpression).Type == UtilConstants.BoolType;
  255. var isIFFUnary = isIIF && (item is UnaryExpression) && (item as UnaryExpression).Operand.Type == UtilConstants.BoolType;
  256. var isIFFBoolBinary = isIIF && (item is BinaryExpression) && (item as BinaryExpression).Type == UtilConstants.BoolType;
  257. var isIFFBoolMethod = isIIF && (item is MethodCallExpression) && (item as MethodCallExpression).Type == UtilConstants.BoolType;
  258. var isFirst = item == args.First();
  259. if (isFirst && isIIF && isConst)
  260. {
  261. var value = (item as ConstantExpression).Value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False();
  262. var methodCallExpressionArgs = new MethodCallExpressionArgs
  263. {
  264. IsMember = true,
  265. MemberName = value,
  266. MemberValue = value
  267. };
  268. model.Args.Add(methodCallExpressionArgs);
  269. }
  270. else if (isIFFUnary && !isFirst)
  271. {
  272. AppendModelByIIFMember(parameter, model, (item as UnaryExpression).Operand);
  273. }
  274. else if (isIFFBoolMember && !isFirst)
  275. {
  276. AppendModelByIIFMember(parameter, model, item);
  277. }
  278. else if (isIFFBoolBinary && !isFirst)
  279. {
  280. AppendModelByIIFBinary(parameter, model, item);
  281. }
  282. else if (isIFFBoolMethod && !isFirst)
  283. {
  284. AppendModelByIIFMethod(parameter, model, item);
  285. }
  286. else if (isBinaryExpression)
  287. {
  288. model.Args.Add(GetMethodCallArgs(parameter, item));
  289. }
  290. else
  291. {
  292. AppendModel(parameter, model, item);
  293. }
  294. }
  295. private void AppendModelByIIFMember(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
  296. {
  297. parameter.CommonTempData = CommonTempDataType.Result;
  298. base.Expression = item;
  299. base.Start();
  300. var methodCallExpressionArgs = new MethodCallExpressionArgs
  301. {
  302. IsMember = parameter.ChildExpression is MemberExpression,
  303. MemberName = parameter.CommonTempData
  304. };
  305. if (methodCallExpressionArgs.IsMember && parameter.ChildExpression != null && parameter.ChildExpression.ToString() == "DateTime.Now")
  306. {
  307. methodCallExpressionArgs.IsMember = false;
  308. }
  309. var value = methodCallExpressionArgs.MemberName;
  310. if (methodCallExpressionArgs.IsMember)
  311. {
  312. var childExpression = parameter.ChildExpression as MemberExpression;
  313. if (childExpression.Expression != null && childExpression.Expression is ConstantExpression)
  314. {
  315. methodCallExpressionArgs.IsMember = false;
  316. }
  317. }
  318. if (!methodCallExpressionArgs.IsMember)
  319. {
  320. var parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.MethodConst + this.Context.ParameterIndex;
  321. this.Context.ParameterIndex++;
  322. methodCallExpressionArgs.MemberName = parameterName;
  323. methodCallExpressionArgs.MemberValue = value;
  324. this.Context.Parameters.Add(new SugarParameter(parameterName, value));
  325. }
  326. model.Args.Add(methodCallExpressionArgs);
  327. parameter.ChildExpression = null;
  328. }
  329. private void AppendModelByIIFBinary(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
  330. {
  331. Check.Exception(true, "The SqlFunc.IIF(arg1,arg2,arg3) , {0} argument do not support ", item.ToString());
  332. }
  333. private void AppendModelByIIFMethod(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
  334. {
  335. var methodExpression = item as MethodCallExpression;
  336. if (methodExpression.Method.Name.IsIn("ToBool", "ToBoolean", "IIF"))
  337. {
  338. model.Args.Add(base.GetMethodCallArgs(parameter, item));
  339. }
  340. else
  341. {
  342. Check.Exception(true, "The SqlFunc.IIF(arg1,arg2,arg3) , {0} argument do not support ", item.ToString());
  343. }
  344. }
  345. private void AppendModel(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
  346. {
  347. parameter.CommonTempData = CommonTempDataType.Result;
  348. base.Expression = item;
  349. base.Start();
  350. var methodCallExpressionArgs = new MethodCallExpressionArgs
  351. {
  352. IsMember = parameter.ChildExpression is MemberExpression && !ExpressionTool.IsConstExpression(parameter.ChildExpression as MemberExpression),
  353. MemberName = parameter.CommonTempData
  354. };
  355. if (methodCallExpressionArgs.IsMember && parameter.ChildExpression != null && parameter.ChildExpression.ToString() == "DateTime.Now")
  356. {
  357. methodCallExpressionArgs.IsMember = false;
  358. }
  359. var value = methodCallExpressionArgs.MemberName;
  360. if (methodCallExpressionArgs.IsMember)
  361. {
  362. var childExpression = parameter.ChildExpression as MemberExpression;
  363. if (childExpression.Expression != null && childExpression.Expression is ConstantExpression)
  364. {
  365. methodCallExpressionArgs.IsMember = false;
  366. }
  367. }
  368. if (!methodCallExpressionArgs.IsMember)
  369. {
  370. var parameterName = this.Context.SqlParameterKeyWord + ExpressionConst.MethodConst + this.Context.ParameterIndex;
  371. this.Context.ParameterIndex++;
  372. methodCallExpressionArgs.MemberName = parameterName;
  373. methodCallExpressionArgs.MemberValue = value;
  374. this.Context.Parameters.Add(new SugarParameter(parameterName, value));
  375. }
  376. model.Args.Add(methodCallExpressionArgs);
  377. parameter.ChildExpression = null;
  378. }
  379. private object GetMdthodValue(string name, MethodCallExpressionModel model)
  380. {
  381. if (IsExtMethod(name))
  382. {
  383. var type = DbType.SqlServer;
  384. if (this.Context is SqlServerExpressionContext)
  385. type = DbType.SqlServer;
  386. else if (this.Context is MySqlExpressionContext)
  387. type = DbType.MySql;
  388. else if (this.Context is SqliteExpressionContext)
  389. type = DbType.Sqlite;
  390. else if (this.Context is OracleExpressionContext)
  391. type = DbType.Oracle;
  392. return this.Context.SqlFuncServices.First(it => it.UniqueMethodName == name).MethodValue(model, type, this.Context);
  393. }
  394. else
  395. {
  396. switch (name)
  397. {
  398. case "IIF":
  399. return this.Context.DbMehtods.IIF(model);
  400. case "HasNumber":
  401. return this.Context.DbMehtods.HasNumber(model);
  402. case "HasValue":
  403. return this.Context.DbMehtods.HasValue(model);
  404. case "IsNullOrEmpty":
  405. return this.Context.DbMehtods.IsNullOrEmpty(model);
  406. case "ToLower":
  407. return this.Context.DbMehtods.ToLower(model);
  408. case "ToUpper":
  409. return this.Context.DbMehtods.ToUpper(model);
  410. case "Trim":
  411. return this.Context.DbMehtods.Trim(model);
  412. case "Contains":
  413. return this.Context.DbMehtods.Contains(model);
  414. case "ContainsArray":
  415. var caResult = this.Context.DbMehtods.ContainsArray(model);
  416. this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
  417. return caResult;
  418. case "Equals":
  419. return this.Context.DbMehtods.Equals(model);
  420. case "DateIsSame":
  421. if (model.Args.Count == 2)
  422. return this.Context.DbMehtods.DateIsSameDay(model);
  423. else
  424. {
  425. var dsResult = this.Context.DbMehtods.DateIsSameByType(model);
  426. this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[2].MemberName.ObjToString());
  427. return dsResult;
  428. }
  429. case "DateAdd":
  430. if (model.Args.Count == 2)
  431. return this.Context.DbMehtods.DateAddDay(model);
  432. else
  433. {
  434. var daResult = this.Context.DbMehtods.DateAddByType(model);
  435. this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[2].MemberName.ObjToString());
  436. return daResult;
  437. }
  438. case "DateValue":
  439. var dvResult = this.Context.DbMehtods.DateValue(model);
  440. this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[1].MemberName.ObjToString());
  441. return dvResult;
  442. case "Between":
  443. return this.Context.DbMehtods.Between(model);
  444. case "StartsWith":
  445. return this.Context.DbMehtods.StartsWith(model);
  446. case "EndsWith":
  447. return this.Context.DbMehtods.EndsWith(model);
  448. case "ToInt32":
  449. return this.Context.DbMehtods.ToInt32(model);
  450. case "ToInt64":
  451. return this.Context.DbMehtods.ToInt64(model);
  452. case "ToDate":
  453. return this.Context.DbMehtods.ToDate(model);
  454. case "ToTime":
  455. return this.Context.DbMehtods.ToTime(model);
  456. case "ToString":
  457. Check.Exception(model.Args.Count > 1, "ToString (Format) is not supported, Use ToString().If time formatting can be used it.Date.Year+\"-\"+it.Data.Month+\"-\"+it.Date.Day ");
  458. return this.Context.DbMehtods.ToString(model);
  459. case "ToDecimal":
  460. return this.Context.DbMehtods.ToDecimal(model);
  461. case "ToGuid":
  462. return this.Context.DbMehtods.ToGuid(model);
  463. case "ToDouble":
  464. return this.Context.DbMehtods.ToDouble(model);
  465. case "ToBool":
  466. return this.Context.DbMehtods.ToBool(model);
  467. case "Substring":
  468. return this.Context.DbMehtods.Substring(model);
  469. case "Replace":
  470. return this.Context.DbMehtods.Replace(model);
  471. case "Length":
  472. return this.Context.DbMehtods.Length(model);
  473. case "AggregateSum":
  474. return this.Context.DbMehtods.AggregateSum(model);
  475. case "AggregateAvg":
  476. return this.Context.DbMehtods.AggregateAvg(model);
  477. case "AggregateMin":
  478. return this.Context.DbMehtods.AggregateMin(model);
  479. case "AggregateMax":
  480. return this.Context.DbMehtods.AggregateMax(model);
  481. case "AggregateCount":
  482. return this.Context.DbMehtods.AggregateCount(model);
  483. case nameof(MappingColumn):
  484. var mappingColumnResult = this.Context.DbMehtods.MappingColumn(model);
  485. var isValid = model.Args[0].IsMember && !model.Args[1].IsMember;
  486. Check.Exception(!isValid, "SqlFunc.MappingColumn parameters error, The property name on the left, string value on the right");
  487. this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[1].MemberName.ObjToString());
  488. return mappingColumnResult;
  489. case "IsNull":
  490. return this.Context.DbMehtods.IsNull(model);
  491. case "MergeString":
  492. return this.Context.DbMehtods.MergeString(model.Args.Select(it => it.MemberName.ObjToString()).ToArray());
  493. case "GetSelfAndAutoFill":
  494. this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
  495. return this.Context.DbMehtods.GetSelfAndAutoFill(model.Args[0].MemberValue.ObjToString(), this.Context.IsSingle);
  496. case "GetDate":
  497. return this.Context.DbMehtods.GetDate();
  498. default:
  499. break;
  500. }
  501. }
  502. return null;
  503. }
  504. private static Dictionary<string, string> MethodMapping = new Dictionary<string, string> {
  505. { "ToString","ToString"},
  506. { "ToInt32","ToInt32"},
  507. { "ToInt16","ToInt32"},
  508. { "ToInt64","ToInt64"},
  509. { "ToDecimal","ToDecimal"},
  510. { "ToDateTime","ToDate"},
  511. { "ToBoolean","ToBool"},
  512. { "ToDouble","ToDouble"},
  513. { "Length","Length"},
  514. { "Replace","Replace"},
  515. { "Contains","Contains"},
  516. { "ContainsArray","ContainsArray"},
  517. { "EndsWith","EndsWith"},
  518. { "StartsWith","StartsWith"},
  519. { "HasValue","HasValue"},
  520. { "Trim","Trim"},
  521. { "Equals","Equals"},
  522. { "ToLower","ToLower"},
  523. { "ToUpper","ToUpper"},
  524. { "Substring","Substring"},
  525. { "DateAdd","DateAdd"}
  526. };
  527. private static Dictionary<string, DateType> MethodTimeMapping = new Dictionary<string, DateType> {
  528. { "AddYears",DateType.Year},
  529. { "AddMonths",DateType.Month},
  530. { "AddDays",DateType.Day},
  531. { "AddHours",DateType.Hour},
  532. { "AddMinutes",DateType.Minute},
  533. { "AddSeconds",DateType.Second},
  534. { "AddMilliseconds",DateType.Millisecond}
  535. };
  536. private bool IsContainsArray(MethodCallExpression express, string methodName, bool isValidNativeMethod)
  537. {
  538. return !isValidNativeMethod && express.Method.DeclaringType.Namespace.IsIn("System.Linq", "System.Collections.Generic") && methodName == "Contains";
  539. }
  540. private bool IsSubMethod(MethodCallExpression express, string methodName)
  541. {
  542. return SubTools.SubItemsConst.Any(it => it.Name == methodName) && express.Object != null && express.Object.Type.Name == "Subqueryable`1";
  543. }
  544. private bool CheckMethod(MethodCallExpression expression)
  545. {
  546. if (IsExtMethod(expression.Method.Name))
  547. return true;
  548. if (expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName)
  549. return false;
  550. else
  551. return true;
  552. }
  553. }
  554. }