LambdaHelper.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6. using System.Reflection;
  7. namespace ShwasherSys.Lambda
  8. {
  9. public static class LambdaHelper
  10. {
  11. /// <summary>
  12. /// 创建 LambdaExpression<Func<T, bool>>
  13. /// </summary>
  14. /// <typeparam name="T"></typeparam>
  15. /// <param name="obj"></param>
  16. /// <param name="left"></param>
  17. /// <returns></returns>
  18. public static Expression<Func<T, bool>> GetExp<T>(this LambdaObject obj, ParameterExpression left = null)
  19. {
  20. Expression<Func<T, bool>> finalExp = null;
  21. left = left ?? Expression.Parameter(typeof(T), "a");
  22. Expression right = GetRightExp<T>(obj, left);
  23. if (right != null) finalExp = Expression.Lambda<Func<T, bool>>(right, left);
  24. return finalExp;
  25. }
  26. /// <summary>
  27. /// 创建 LambdaExpression<Func<T, bool>>
  28. /// </summary>
  29. /// <typeparam name="T"></typeparam>
  30. /// <param name="objs"></param>
  31. /// <param name="left"></param>
  32. /// <returns></returns>
  33. public static Expression<Func<T, bool>> GetExp<T>(this List<LambdaObject> objs, ParameterExpression left = null)
  34. {
  35. Expression<Func<T, bool>> finalExp = null;
  36. left = left ?? Expression.Parameter(typeof(T), "a");
  37. Expression right = null;
  38. foreach (var obj in objs)
  39. {
  40. Expression exp = GetRightExp<T>(obj, left);
  41. right = right == null ? exp : CombineExp(right, exp, obj.LogicType);
  42. }
  43. if (right != null) finalExp = Expression.Lambda<Func<T, bool>>(right, left);
  44. return finalExp;
  45. }
  46. /// <summary>
  47. /// 创建 MemberExpression
  48. /// </summary>
  49. /// <typeparam name="T"></typeparam>
  50. /// <param name="obj"></param>
  51. /// <param name="left"></param>
  52. /// <returns></returns>
  53. public static Expression GetRightExp<T>(LambdaObject obj, ParameterExpression left)
  54. {
  55. left = left ?? Expression.Parameter(typeof(T), "a");//创建参数a
  56. string fieldName = obj.FieldName;
  57. //var fieldValue = obj.FieldValue;
  58. MemberExpression member = Expression.PropertyOrField(left, fieldName);
  59. Expression rignt = null;
  60. if (obj.Children != null && obj.Children.Any())
  61. rignt = GetRightExps<T>(obj.Children, left);
  62. else
  63. {
  64. ConstantExpression constant = GetConstantExp<T>(obj);
  65. switch ((int)obj.ExpType)
  66. {
  67. case 0:
  68. rignt = constant != null ? Expression.Equal(member, constant) : null;
  69. break;
  70. case 1:
  71. rignt = constant != null ? Expression.NotEqual(member, constant) : null;
  72. break;
  73. case 2:
  74. rignt = constant != null ? Expression.GreaterThan(member, constant) : null;
  75. break;
  76. case 3:
  77. rignt = constant != null ? Expression.LessThan(member, constant) : null;
  78. break;
  79. case 4:
  80. rignt = constant != null ? Expression.GreaterThanOrEqual(member, constant) : null;
  81. break;
  82. case 5:
  83. rignt = constant != null ? Expression.LessThanOrEqual(member, constant) : null;
  84. break;
  85. case 6:
  86. rignt = GetRightExp_Contains<T>(obj, left);
  87. break;
  88. case 7:
  89. rignt = GetRightExp_NotContains<T>(obj, left);
  90. break;
  91. case 8:
  92. break;
  93. }
  94. }
  95. return rignt;
  96. }
  97. /// <summary>
  98. /// 创建 MemberExpression
  99. /// </summary>
  100. /// <typeparam name="T"></typeparam>
  101. /// <param name="objs"></param>
  102. /// <param name="left"></param>
  103. /// <returns></returns>
  104. public static Expression GetRightExps<T>(List<LambdaObject> objs, ParameterExpression left)
  105. {
  106. left = left ?? Expression.Parameter(typeof(T), "a");//创建参数a
  107. Expression right = null;
  108. foreach (var obj in objs)
  109. {
  110. Expression exp = GetRightExp<T>(obj, left);
  111. right = right == null ? exp : CombineExp(right, exp, obj.LogicType);
  112. }
  113. return right;
  114. }
  115. /// <summary>
  116. /// 创建 ConstantExpression
  117. /// </summary>
  118. private static ConstantExpression GetConstantExp<T>(LambdaObject obj)
  119. {
  120. var fieldValue = obj.FieldValue;
  121. ConstantExpression constant = null;
  122. switch ((int)obj.FieldType)
  123. {
  124. case 0:
  125. constant = Expression.Constant(fieldValue is string ? fieldValue : fieldValue.ToString(), typeof(string));
  126. break;
  127. case 1:
  128. if (fieldValue is int)
  129. constant = Expression.Constant(fieldValue, typeof(int));
  130. else if (int.TryParse(fieldValue.ToString(), out int newValue))
  131. constant = Expression.Constant(newValue, typeof(int));
  132. break;
  133. case 2:
  134. if (fieldValue is int)
  135. constant = Expression.Constant(fieldValue, typeof(int?));
  136. else if (int.TryParse(fieldValue.ToString(), out int newValue))
  137. constant = Expression.Constant(newValue, typeof(int?));
  138. break;
  139. case 3:
  140. if (fieldValue is bool)
  141. constant = Expression.Constant(fieldValue, typeof(bool));
  142. else if (bool.TryParse(fieldValue.ToString(), out bool newValue))
  143. constant = Expression.Constant(newValue, typeof(bool));
  144. break;
  145. case 4:
  146. if (fieldValue is bool)
  147. constant = Expression.Constant(fieldValue, typeof(bool?));
  148. else if (bool.TryParse(fieldValue.ToString(), out bool newValue))
  149. constant = Expression.Constant(newValue, typeof(bool?));
  150. break;
  151. case 5:
  152. if (fieldValue is DateTime)
  153. constant = Expression.Constant(fieldValue, typeof(DateTime));
  154. else if (DateTime.TryParse(fieldValue.ToString(), out DateTime newValue))
  155. constant = Expression.Constant(newValue, typeof(DateTime));
  156. break;
  157. case 6:
  158. if (fieldValue is DateTime)
  159. constant = Expression.Constant(fieldValue, typeof(DateTime?));
  160. else if (DateTime.TryParse(fieldValue.ToString(), out DateTime newValue))
  161. constant = Expression.Constant(newValue, typeof(DateTime?));
  162. break;
  163. case 7:
  164. if (fieldValue is decimal)
  165. constant = Expression.Constant(fieldValue, typeof(decimal));
  166. else if (decimal.TryParse(fieldValue.ToString(), out decimal newValue))
  167. constant = Expression.Constant(newValue, typeof(decimal));
  168. break;
  169. case 8:
  170. if (fieldValue is decimal?)
  171. constant = Expression.Constant(fieldValue, typeof(decimal?));
  172. else if (decimal.TryParse(fieldValue.ToString(), out decimal newValue))
  173. constant = Expression.Constant(newValue, typeof(decimal?));
  174. break;
  175. }
  176. return constant;
  177. }
  178. /// <summary>
  179. /// 创建lambda表达式:p=>p.propertyName.Contains(propertyValue)
  180. /// </summary>
  181. /// <typeparam name="T"></typeparam>
  182. /// <param name="obj"></param>
  183. /// <param name="left"></param>
  184. /// <returns></returns>
  185. public static Expression GetRightExp_Contains<T>(LambdaObject obj, ParameterExpression left = null)
  186. {
  187. string fieldName = obj.FieldName;
  188. var fieldValue = obj.FieldValue;
  189. left = left ?? Expression.Parameter(typeof(T), "a");//创建参数a
  190. MemberExpression member = Expression.PropertyOrField(left, fieldName);
  191. Expression right = null;
  192. switch (obj.FieldType)
  193. {
  194. case LambdaFieldType.S:
  195. var method1 = typeof(string).GetMethod("Contains", new[] { typeof(string) });
  196. if (method1 == null) return null;
  197. if (fieldValue is string)
  198. {
  199. ConstantExpression constant = Expression.Constant(fieldValue.ToString());//创建常数
  200. right = Expression.Call(member, method1, constant);
  201. }
  202. else
  203. {
  204. foreach (var o in (IEnumerable)fieldValue)
  205. {
  206. ConstantExpression constant = Expression.Constant(o);
  207. var temp = Expression.Call(member, method1, constant);
  208. right = right == null ? temp : CombineExp(right, temp, LogicType.Or);
  209. }
  210. }
  211. break;
  212. case LambdaFieldType.I:
  213. var method2 = typeof(int).GetMethod("Contains", new[] { typeof(int) });
  214. if (method2 == null) return null;
  215. if (fieldValue is int)
  216. {
  217. ConstantExpression constant = Expression.Constant(fieldValue.ToString());
  218. right = Expression.Call(member, method2, constant);
  219. }
  220. else
  221. {
  222. foreach (var o in (IEnumerable)fieldValue)
  223. {
  224. ConstantExpression constant = Expression.Constant(o);
  225. var temp = Expression.Call(member, method2, constant);
  226. right = right == null ? temp : CombineExp(right, temp, LogicType.Or);
  227. }
  228. }
  229. break;
  230. case LambdaFieldType.B:
  231. var method3 = typeof(bool).GetMethod("Contains", new[] { typeof(bool) });
  232. if (method3 == null) return null;
  233. if (fieldValue is bool)
  234. {
  235. ConstantExpression constant = Expression.Constant(fieldValue.ToString());
  236. right = Expression.Call(member, method3, constant);
  237. }
  238. break;
  239. }
  240. return right;
  241. }
  242. /// <summary>
  243. /// 创建lambda表达式:!(p=>p.propertyName.Contains(propertyValue))
  244. /// </summary>
  245. /// <typeparam name="T"></typeparam>
  246. /// <param name="obj"></param>
  247. /// <param name="left"></param>
  248. /// <returns></returns>
  249. public static Expression GetRightExp_NotContains<T>(LambdaObject obj, ParameterExpression left = null)
  250. {
  251. return Expression.Not(GetRightExp_Contains<T>(obj, left));
  252. }
  253. /// <summary>
  254. /// 拼接 Expression
  255. /// </summary>
  256. /// <param name="exp1"></param>
  257. /// <param name="exp2"></param>
  258. /// <param name="type"></param>
  259. /// <returns></returns>
  260. public static Expression CombineExp(this Expression exp1, Expression exp2, LogicType type)
  261. {
  262. Expression exp = exp1;
  263. if (exp1 == null || exp2 == null)
  264. {
  265. return exp1;
  266. }
  267. switch ((int)type)
  268. {
  269. case 0:
  270. exp = Expression.And(exp1, exp2);
  271. break;
  272. case 1:
  273. exp = Expression.Or(exp1, exp2);
  274. break;
  275. }
  276. return exp;
  277. }
  278. #region 暂未用到
  279. /// <summary>
  280. /// 创建 MemberExpression
  281. /// </summary>
  282. /// <typeparam name="T"></typeparam>
  283. /// <param name="objs"></param>
  284. /// <param name="left"></param>
  285. /// <returns></returns>
  286. public static Expression GetRightExp2<T>(List<LambdaObject> objs, ParameterExpression left)
  287. {
  288. Expression right = null;
  289. foreach (var obj in objs)
  290. {
  291. Expression exp = null;
  292. if (obj.Children.Any())
  293. {
  294. exp = GetRightExps<T>(obj.Children, left);
  295. right = right == null ? exp : CombineExp(right, exp, obj.LogicType);
  296. continue;
  297. }
  298. switch ((int)obj.ExpType)
  299. {
  300. case 0:
  301. exp = GetRightExp_Equal<T>(obj, left);
  302. break;
  303. case 1:
  304. exp = GetRightExp_NotEqual<T>(obj, left);
  305. break;
  306. case 2:
  307. break;
  308. case 3:
  309. break;
  310. case 4:
  311. break;
  312. case 5:
  313. break;
  314. case 6:
  315. break;
  316. case 7:
  317. exp = GetRightExp_Contains<T>(obj);
  318. break;
  319. case 8:
  320. exp = GetRightExp_NotContains<T>(obj);
  321. break;
  322. }
  323. right = right == null ? exp : CombineExp(right, exp, obj.LogicType);
  324. }
  325. return right;
  326. }
  327. /// <summary>
  328. /// 创建lambda表达式:p=>p.propertyName == propertyValue
  329. /// </summary>
  330. public static Expression GetRightExp_Equal<T>(LambdaObject obj, ParameterExpression left = null)
  331. {
  332. //Expression<Func<T, bool>> exp = null;
  333. string fieldName = obj.FieldName;
  334. var fieldValue = obj.FieldValue;
  335. left = left ?? Expression.Parameter(typeof(T), "a");//创建参数a
  336. MemberExpression member = Expression.PropertyOrField(left, fieldName);
  337. Expression right = null;
  338. switch ((int)obj.FieldType)
  339. {
  340. case 0:
  341. if (fieldValue is string)
  342. {
  343. ConstantExpression constant = Expression.Constant(fieldValue);//创建常数
  344. //exp= Expression.Lambda<Func<T, bool>>(Expression.Equal(member, constant), left);
  345. right = Expression.Equal(member, constant);
  346. }
  347. //else if (os is List<string>)
  348. //{
  349. // foreach (var o in (List<string>) os)
  350. // {
  351. // ConstantExpression constant = Expression.Constant(o);
  352. // var temp = Expression.Equal(member, constant);
  353. // right = CombineExp(right,temp,obj.LogicType);
  354. // }
  355. //}
  356. break;
  357. case 1:
  358. if (fieldValue is int)
  359. {
  360. ConstantExpression constant = Expression.Constant(fieldValue);
  361. right = Expression.Equal(member, constant);
  362. }
  363. break;
  364. case 2:
  365. if (fieldValue is bool)
  366. {
  367. ConstantExpression constant = Expression.Constant(fieldValue);
  368. right = Expression.Equal(member, constant);
  369. }
  370. break;
  371. }
  372. return right;
  373. }
  374. /// <summary>
  375. /// 创建lambda表达式:p=>p.propertyName != propertyValue
  376. /// </summary>
  377. public static Expression GetRightExp_NotEqual<T>(LambdaObject obj, ParameterExpression left = null)
  378. {
  379. string fieldName = obj.FieldName;
  380. var fieldValue = obj.FieldValue;
  381. left = left ?? Expression.Parameter(typeof(T), "a");//创建参数a
  382. MemberExpression member = Expression.PropertyOrField(left, fieldName);
  383. Expression right = null;
  384. switch ((int)obj.FieldType)
  385. {
  386. case 0:
  387. if (fieldValue is string)
  388. {
  389. ConstantExpression constant = Expression.Constant(fieldValue);
  390. right = Expression.NotEqual(member, constant);
  391. }
  392. break;
  393. case 1:
  394. if (fieldValue is int)
  395. {
  396. ConstantExpression constant = Expression.Constant(fieldValue);
  397. right = Expression.NotEqual(member, constant);
  398. }
  399. break;
  400. case 2:
  401. if (fieldValue is bool)
  402. {
  403. ConstantExpression constant = Expression.Constant(fieldValue);
  404. right = Expression.NotEqual(member, constant);
  405. }
  406. break;
  407. }
  408. return right;
  409. }
  410. /// <summary>
  411. /// 创建lambda表达式:p=>true
  412. /// </summary>
  413. /// <typeparam name="T"></typeparam>
  414. /// <returns></returns>
  415. public static Expression<Func<T, bool>> True<T>()
  416. {
  417. return p => true;
  418. }
  419. /// <summary>
  420. /// 创建lambda表达式:p=>false
  421. /// </summary>
  422. /// <typeparam name="T"></typeparam>
  423. /// <returns></returns>
  424. public static Expression<Func<T, bool>> False<T>()
  425. {
  426. return p => false;
  427. }
  428. /// <summary>
  429. /// 创建lambda表达式:p=>p.propertyName
  430. /// </summary>
  431. /// <typeparam name="T"></typeparam>
  432. /// <typeparam name="TKey"></typeparam>
  433. /// <param name="propertyName"></param>
  434. /// <returns></returns>
  435. public static Expression<Func<T, TKey>> GetOrderExpression<T, TKey>(string propertyName)
  436. {
  437. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");
  438. return Expression.Lambda<Func<T, TKey>>(Expression.Property(parameter, propertyName), parameter);
  439. }
  440. /// <summary>
  441. /// 创建lambda表达式:p=>p.propertyName == propertyValue
  442. /// </summary>
  443. /// <returns></returns>
  444. public static Expression<Func<T, bool>> CreateEqual<T>(string propertyName, string propertyValue)
  445. {
  446. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");//创建参数p
  447. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  448. ConstantExpression constant = Expression.Constant(propertyValue);//创建常数
  449. return Expression.Lambda<Func<T, bool>>(Expression.Equal(member, constant), parameter);
  450. }
  451. /// <summary>
  452. /// 创建lambda表达式:p=>p.propertyName != propertyValue
  453. /// </summary>
  454. /// <typeparam name="T"></typeparam>
  455. /// <param name="propertyName"></param>
  456. /// <param name="propertyValue"></param>
  457. /// <returns></returns>
  458. public static Expression<Func<T, bool>> CreateNotEqual<T>(string propertyName, string propertyValue)
  459. {
  460. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");//创建参数p
  461. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  462. ConstantExpression constant = Expression.Constant(propertyValue);//创建常数
  463. return Expression.Lambda<Func<T, bool>>(Expression.NotEqual(member, constant), parameter);
  464. }
  465. /// <summary>
  466. /// 创建lambda表达式:p=>p.propertyName > propertyValue
  467. /// </summary>
  468. /// <typeparam name="T"></typeparam>
  469. /// <returns></returns>
  470. public static Expression<Func<T, bool>> CreateGreaterThan<T>(string propertyName, string propertyValue)
  471. {
  472. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");//创建参数p
  473. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  474. ConstantExpression constant = Expression.Constant(propertyValue);//创建常数
  475. return Expression.Lambda<Func<T, bool>>(Expression.GreaterThan(member, constant), parameter);
  476. }
  477. /// <summary>
  478. /// 创建lambda表达式:p=>p.propertyName < propertyValue
  479. /// </summary>
  480. /// <typeparam name="T"></typeparam>
  481. /// <returns></returns>
  482. public static Expression<Func<T, bool>> CreateLessThan<T>(string propertyName, string propertyValue)
  483. {
  484. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");//创建参数p
  485. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  486. ConstantExpression constant = Expression.Constant(propertyValue);//创建常数
  487. return Expression.Lambda<Func<T, bool>>(Expression.LessThan(member, constant), parameter);
  488. }
  489. /// <summary>
  490. /// 创建lambda表达式:p=>p.propertyName >= propertyValue
  491. /// </summary>
  492. /// <typeparam name="T"></typeparam>
  493. /// <returns></returns>
  494. public static Expression<Func<T, bool>> CreateGreaterThanOrEqual<T>(string propertyName, string propertyValue)
  495. {
  496. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");//创建参数p
  497. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  498. ConstantExpression constant = Expression.Constant(propertyValue);//创建常数
  499. return Expression.Lambda<Func<T, bool>>(Expression.GreaterThanOrEqual(member, constant), parameter);
  500. }
  501. /// <summary>
  502. /// 创建lambda表达式:p=>p.propertyName <= propertyValue
  503. /// </summary>
  504. /// <typeparam name="T"></typeparam>
  505. /// <returns></returns>
  506. public static Expression<Func<T, bool>> CreateLessThanOrEqual<T>(string propertyName, string propertyValue)
  507. {
  508. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");//创建参数p
  509. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  510. ConstantExpression constant = Expression.Constant(propertyValue);//创建常数
  511. return Expression.Lambda<Func<T, bool>>(Expression.LessThanOrEqual(member, constant), parameter);
  512. }
  513. /// <summary>
  514. /// 创建lambda表达式:p=>p.propertyName.Contains(propertyValue)
  515. /// </summary>
  516. /// <typeparam name="T"></typeparam>
  517. /// <returns></returns>
  518. public static Expression<Func<T, bool>> GetContains<T>(string propertyName, string propertyValue)
  519. {
  520. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");
  521. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  522. MethodInfo method = typeof(string).GetMethod("Contains", new[] { typeof(string) });
  523. ConstantExpression constant = Expression.Constant(propertyValue, typeof(string));
  524. return Expression.Lambda<Func<T, bool>>(Expression.Call(member, method, constant), parameter);
  525. }
  526. /// <summary>
  527. /// 创建lambda表达式:!(p=>p.propertyName.Contains(propertyValue))
  528. /// </summary>
  529. /// <typeparam name="T"></typeparam>
  530. /// <returns></returns>
  531. public static Expression<Func<T, bool>> GetNotContains<T>(string propertyName, string propertyValue)
  532. {
  533. ParameterExpression parameter = Expression.Parameter(typeof(T), "p");
  534. MemberExpression member = Expression.PropertyOrField(parameter, propertyName);
  535. MethodInfo method = typeof(string).GetMethod("Contains", new[] { typeof(string) });
  536. ConstantExpression constant = Expression.Constant(propertyValue, typeof(string));
  537. return Expression.Lambda<Func<T, bool>>(Expression.Not(Expression.Call(member, method, constant)), parameter);
  538. }
  539. #endregion
  540. }
  541. public class LambdaObject
  542. {
  543. public LambdaObject()
  544. {
  545. }
  546. public LambdaObject(string fieldName, object fieldValue, LambdaExpType expType = LambdaExpType.Contains, LambdaFieldType fieldType = LambdaFieldType.S, LogicType logicType = LogicType.And)
  547. {
  548. FieldName = fieldName;
  549. FieldValue = fieldValue;
  550. FieldType = fieldType;
  551. ExpType = expType;
  552. LogicType = logicType;
  553. }
  554. public string FieldName { get; set; }
  555. public object FieldValue { get; set; }
  556. public LambdaFieldType FieldType { get; set; }
  557. public LambdaExpType ExpType { get; set; }
  558. public LogicType LogicType { get; set; }
  559. public List<LambdaObject> Children { get; set; }
  560. }
  561. /// <summary>
  562. /// 表达式类型
  563. /// </summary>
  564. public enum LambdaExpType
  565. {
  566. Equal
  567. , NotEqual
  568. , Greater
  569. , Less
  570. , GreaterOrEqual
  571. , LessOrEqual
  572. , Contains
  573. , NotContains
  574. }
  575. /// <summary>
  576. /// 字段类型
  577. /// </summary>
  578. public enum LambdaFieldType
  579. {
  580. /// <summary>
  581. /// string
  582. /// </summary>
  583. S = 0,
  584. /// <summary>
  585. /// int
  586. /// </summary>
  587. I = 1,
  588. /// <summary>
  589. /// int?
  590. /// </summary>
  591. Inull = 2,
  592. /// <summary>
  593. /// bool
  594. /// </summary>
  595. B = 3,
  596. /// <summary>
  597. /// bool?
  598. /// </summary>
  599. Bnull = 4,
  600. /// <summary>
  601. /// Datetime
  602. /// </summary>
  603. D = 5,
  604. /// <summary>
  605. /// Datetime?
  606. /// </summary>
  607. Dnull = 6,
  608. /// <summary>
  609. /// Decimal
  610. /// </summary>
  611. Dec = 7,
  612. /// <summary>
  613. /// Decimal?
  614. /// </summary>
  615. DecNull = 8
  616. }
  617. /// <summary>
  618. /// 拼接时 AND || OR
  619. /// </summary>
  620. public enum LogicType
  621. {
  622. And,
  623. Or
  624. }
  625. }