Expressionable.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. namespace SqlSugar
  7. {
  8. public class Expressionable<T> where T : class, new()
  9. {
  10. Expression<Func<T, bool>> _exp = null;
  11. public Expressionable<T> And(Expression<Func<T, bool>> exp)
  12. {
  13. if (_exp == null)
  14. _exp = exp;
  15. else
  16. _exp = Expression.Lambda<Func<T, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  17. return this;
  18. }
  19. public Expressionable<T> AndIF(bool isAnd, Expression<Func<T, bool>> exp)
  20. {
  21. if (isAnd)
  22. And(exp);
  23. return this;
  24. }
  25. public Expressionable<T> Or(Expression<Func<T, bool>> exp)
  26. {
  27. if (_exp == null)
  28. _exp = exp;
  29. else
  30. _exp = Expression.Lambda<Func<T, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  31. return this;
  32. }
  33. public Expressionable<T> OrIF(bool isOr, Expression<Func<T, bool>> exp)
  34. {
  35. if (isOr)
  36. Or(exp);
  37. return this;
  38. }
  39. public Expression<Func<T, bool>> ToExpression()
  40. {
  41. if (_exp == null)
  42. _exp = it => true;
  43. return _exp;
  44. }
  45. }
  46. public class Expressionable<T, T2> where T : class, new() where T2 : class, new()
  47. {
  48. Expression<Func<T, T2, bool>> _exp = null;
  49. public Expressionable<T, T2> And(Expression<Func<T, T2, bool>> exp)
  50. {
  51. if (_exp == null)
  52. _exp = exp;
  53. else
  54. _exp = Expression.Lambda<Func<T, T2, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  55. return this;
  56. }
  57. public Expressionable<T, T2> AndIF(bool isAnd, Expression<Func<T, T2, bool>> exp)
  58. {
  59. if (isAnd)
  60. And(exp);
  61. return this;
  62. }
  63. public Expressionable<T, T2> Or(Expression<Func<T, T2, bool>> exp)
  64. {
  65. if (_exp == null)
  66. _exp = exp;
  67. else
  68. _exp = Expression.Lambda<Func<T, T2, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  69. return this;
  70. }
  71. public Expressionable<T, T2> OrIF(bool isOr, Expression<Func<T, T2, bool>> exp)
  72. {
  73. if (isOr)
  74. Or(exp);
  75. return this;
  76. }
  77. public Expression<Func<T, T2, bool>> ToExpression()
  78. {
  79. if (_exp == null)
  80. _exp = (it, t2) => true;
  81. return _exp;
  82. }
  83. }
  84. public class Expressionable<T, T2, T3> where T : class, new() where T2 : class, new() where T3 : class, new()
  85. {
  86. Expression<Func<T, T2, T3, bool>> _exp = null;
  87. public Expressionable<T, T2, T3> And(Expression<Func<T, T2, T3, bool>> exp)
  88. {
  89. if (_exp == null)
  90. _exp = exp;
  91. else
  92. _exp = Expression.Lambda<Func<T, T2, T3, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  93. return this;
  94. }
  95. public Expressionable<T, T2, T3> AndIF(bool isAnd, Expression<Func<T, T2, T3, bool>> exp)
  96. {
  97. if (isAnd)
  98. And(exp);
  99. return this;
  100. }
  101. public Expressionable<T, T2, T3> Or(Expression<Func<T, T2, T3, bool>> exp)
  102. {
  103. if (_exp == null)
  104. _exp = exp;
  105. else
  106. _exp = Expression.Lambda<Func<T, T2, T3, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  107. return this;
  108. }
  109. public Expressionable<T, T2, T3> OrIF(bool isOr, Expression<Func<T, T2, T3, bool>> exp)
  110. {
  111. if (isOr)
  112. Or(exp);
  113. return this;
  114. }
  115. public Expression<Func<T, T2, T3, bool>> ToExpression()
  116. {
  117. if (_exp == null)
  118. _exp = (it, t2, t3) => true;
  119. return _exp;
  120. }
  121. }
  122. public class Expressionable<T, T2, T3, T4> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
  123. {
  124. Expression<Func<T, T2, T3, T4, bool>> _exp = null;
  125. public Expressionable<T, T2, T3, T4> And(Expression<Func<T, T2, T3, T4, bool>> exp)
  126. {
  127. if (_exp == null)
  128. _exp = exp;
  129. else
  130. _exp = Expression.Lambda<Func<T, T2, T3, T4, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  131. return this;
  132. }
  133. public Expressionable<T, T2, T3, T4> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, bool>> exp)
  134. {
  135. if (isAnd)
  136. And(exp);
  137. return this;
  138. }
  139. public Expressionable<T, T2, T3, T4> Or(Expression<Func<T, T2, T3, T4, bool>> exp)
  140. {
  141. if (_exp == null)
  142. _exp = exp;
  143. else
  144. _exp = Expression.Lambda<Func<T, T2, T3, T4, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  145. return this;
  146. }
  147. public Expressionable<T, T2, T3, T4> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, bool>> exp)
  148. {
  149. if (isOr)
  150. Or(exp);
  151. return this;
  152. }
  153. public Expression<Func<T, T2, T3, T4, bool>> ToExpression()
  154. {
  155. if (_exp == null)
  156. _exp = (it, t2, t3, t4) => true;
  157. return _exp;
  158. }
  159. }
  160. public class Expressionable<T, T2, T3, T4, T5> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
  161. {
  162. Expression<Func<T, T2, T3, T4, T5, bool>> _exp = null;
  163. public Expressionable<T, T2, T3, T4, T5> And(Expression<Func<T, T2, T3, T4, T5, bool>> exp)
  164. {
  165. if (_exp == null)
  166. _exp = exp;
  167. else
  168. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  169. return this;
  170. }
  171. public Expressionable<T, T2, T3, T4, T5> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, bool>> exp)
  172. {
  173. if (isAnd)
  174. And(exp);
  175. return this;
  176. }
  177. public Expressionable<T, T2, T3, T4, T5> Or(Expression<Func<T, T2, T3, T4, T5, bool>> exp)
  178. {
  179. if (_exp == null)
  180. _exp = exp;
  181. else
  182. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  183. return this;
  184. }
  185. public Expressionable<T, T2, T3, T4, T5> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, bool>> exp)
  186. {
  187. if (isOr)
  188. Or(exp);
  189. return this;
  190. }
  191. public Expression<Func<T, T2, T3, T4, T5, bool>> ToExpression()
  192. {
  193. if (_exp == null)
  194. _exp = (it, t2, t3, t4, T5) => true;
  195. return _exp;
  196. }
  197. }
  198. public class Expressionable<T, T2, T3, T4, T5, T6> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new()
  199. {
  200. Expression<Func<T, T2, T3, T4, T5, T6, bool>> _exp = null;
  201. public Expressionable<T, T2, T3, T4, T5, T6> And(Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
  202. {
  203. if (_exp == null)
  204. _exp = exp;
  205. else
  206. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  207. return this;
  208. }
  209. public Expressionable<T, T2, T3, T4, T5, T6> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
  210. {
  211. if (isAnd)
  212. And(exp);
  213. return this;
  214. }
  215. public Expressionable<T, T2, T3, T4, T5, T6> Or(Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
  216. {
  217. if (_exp == null)
  218. _exp = exp;
  219. else
  220. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  221. return this;
  222. }
  223. public Expressionable<T, T2, T3, T4, T5, T6> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
  224. {
  225. if (isOr)
  226. Or(exp);
  227. return this;
  228. }
  229. public Expression<Func<T, T2, T3, T4, T5, T6, bool>> ToExpression()
  230. {
  231. if (_exp == null)
  232. _exp = (it, t2, t3, t4, T5, t6) => true;
  233. return _exp;
  234. }
  235. }
  236. public class Expressionable<T, T2, T3, T4, T5, T6,T7> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new()
  237. {
  238. Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> _exp = null;
  239. public Expressionable<T, T2, T3, T4, T5, T6,T7> And(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
  240. {
  241. if (_exp == null)
  242. _exp = exp;
  243. else
  244. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6,T7, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  245. return this;
  246. }
  247. public Expressionable<T, T2, T3, T4, T5, T6,T7> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
  248. {
  249. if (isAnd)
  250. And(exp);
  251. return this;
  252. }
  253. public Expressionable<T, T2, T3, T4, T5, T6,T7> Or(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
  254. {
  255. if (_exp == null)
  256. _exp = exp;
  257. else
  258. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6,T7, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  259. return this;
  260. }
  261. public Expressionable<T, T2, T3, T4, T5, T6,T7> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
  262. {
  263. if (isOr)
  264. Or(exp);
  265. return this;
  266. }
  267. public Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> ToExpression()
  268. {
  269. if (_exp == null)
  270. _exp = (it, t2, t3, t4, T5, t6,t7) => true;
  271. return _exp;
  272. }
  273. }
  274. public class Expressionable<T, T2, T3, T4, T5, T6, T7 , T8> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new()
  275. {
  276. Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> _exp = null;
  277. public Expressionable<T, T2, T3, T4, T5, T6, T7,T8> And(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
  278. {
  279. if (_exp == null)
  280. _exp = exp;
  281. else
  282. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  283. return this;
  284. }
  285. public Expressionable<T, T2, T3, T4, T5, T6, T7,T8> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
  286. {
  287. if (isAnd)
  288. And(exp);
  289. return this;
  290. }
  291. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
  292. {
  293. if (_exp == null)
  294. _exp = exp;
  295. else
  296. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  297. return this;
  298. }
  299. public Expressionable<T, T2, T3, T4, T5, T6, T7,T8> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
  300. {
  301. if (isOr)
  302. Or(exp);
  303. return this;
  304. }
  305. public Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> ToExpression()
  306. {
  307. if (_exp == null)
  308. _exp = (it, t2, t3, t4, T5, t6, t7,t8) => true;
  309. return _exp;
  310. }
  311. }
  312. public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
  313. {
  314. Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> _exp = null;
  315. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
  316. {
  317. if (_exp == null)
  318. _exp = exp;
  319. else
  320. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  321. return this;
  322. }
  323. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
  324. {
  325. if (isAnd)
  326. And(exp);
  327. return this;
  328. }
  329. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
  330. {
  331. if (_exp == null)
  332. _exp = exp;
  333. else
  334. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  335. return this;
  336. }
  337. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
  338. {
  339. if (isOr)
  340. Or(exp);
  341. return this;
  342. }
  343. public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> ToExpression()
  344. {
  345. if (_exp == null)
  346. _exp = (it, t2, t3, t4, T5, t6, t7, t8,t9) => true;
  347. return _exp;
  348. }
  349. }
  350. public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
  351. {
  352. Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> _exp = null;
  353. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
  354. {
  355. if (_exp == null)
  356. _exp = exp;
  357. else
  358. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  359. return this;
  360. }
  361. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
  362. {
  363. if (isAnd)
  364. And(exp);
  365. return this;
  366. }
  367. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
  368. {
  369. if (_exp == null)
  370. _exp = exp;
  371. else
  372. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  373. return this;
  374. }
  375. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
  376. {
  377. if (isOr)
  378. Or(exp);
  379. return this;
  380. }
  381. public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> ToExpression()
  382. {
  383. if (_exp == null)
  384. _exp = (it, t2, t3, t4, T5, t6, t7, t8, t9, t10) => true;
  385. return _exp;
  386. }
  387. }
  388. public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
  389. {
  390. Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> _exp = null;
  391. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> exp)
  392. {
  393. if (_exp == null)
  394. _exp = exp;
  395. else
  396. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  397. return this;
  398. }
  399. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> exp)
  400. {
  401. if (isAnd)
  402. And(exp);
  403. return this;
  404. }
  405. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> exp)
  406. {
  407. if (_exp == null)
  408. _exp = exp;
  409. else
  410. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  411. return this;
  412. }
  413. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> exp)
  414. {
  415. if (isOr)
  416. Or(exp);
  417. return this;
  418. }
  419. public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> ToExpression()
  420. {
  421. if (_exp == null)
  422. _exp = (it, t2, t3, t4, T5, t6, t7, t8, t9, t10,t11) => true;
  423. return _exp;
  424. }
  425. }
  426. public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
  427. {
  428. Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> _exp = null;
  429. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> exp)
  430. {
  431. if (_exp == null)
  432. _exp = exp;
  433. else
  434. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
  435. return this;
  436. }
  437. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> exp)
  438. {
  439. if (isAnd)
  440. And(exp);
  441. return this;
  442. }
  443. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> exp)
  444. {
  445. if (_exp == null)
  446. _exp = exp;
  447. else
  448. _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
  449. return this;
  450. }
  451. public Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> exp)
  452. {
  453. if (isOr)
  454. Or(exp);
  455. return this;
  456. }
  457. public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> ToExpression()
  458. {
  459. if (_exp == null)
  460. _exp = (it, t2, t3, t4, T5, t6, t7, t8, t9, t10, t11,t12) => true;
  461. return _exp;
  462. }
  463. }
  464. public class Expressionable
  465. {
  466. public static Expressionable<T> Create<T>() where T : class, new()
  467. {
  468. return new Expressionable<T>();
  469. }
  470. public static Expressionable<T, T2> Create<T, T2>() where T : class, new() where T2 : class, new()
  471. {
  472. return new Expressionable<T, T2>();
  473. }
  474. public static Expressionable<T, T2, T3> Create<T, T2, T3>() where T : class, new() where T2 : class, new() where T3 : class, new()
  475. {
  476. return new Expressionable<T, T2, T3>();
  477. }
  478. public static Expressionable<T, T2, T3, T4> Create<T, T2, T3, T4>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
  479. {
  480. return new Expressionable<T, T2, T3, T4>();
  481. }
  482. public static Expressionable<T, T2, T3, T4, T5> Create<T, T2, T3, T4, T5>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
  483. {
  484. return new Expressionable<T, T2, T3, T4, T5>();
  485. }
  486. public static Expressionable<T, T2, T3, T4, T5, T6> Create<T, T2, T3, T4, T5, T6>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new()
  487. {
  488. return new Expressionable<T, T2, T3, T4, T5, T6>();
  489. }
  490. public static Expressionable<T, T2, T3, T4, T5, T6,T7> Create<T, T2, T3, T4, T5, T6,T7>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new()
  491. {
  492. return new Expressionable<T, T2, T3, T4, T5, T6,T7>();
  493. }
  494. public static Expressionable<T, T2, T3, T4, T5, T6, T7,T8> Create<T, T2, T3, T4, T5, T6, T7,T8>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new()
  495. {
  496. return new Expressionable<T, T2, T3, T4, T5, T6, T7,T8>();
  497. }
  498. public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> Create<T, T2, T3, T4, T5, T6, T7, T8,T9>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
  499. {
  500. return new Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9>();
  501. }
  502. public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> Create<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new() where T10 : class, new()
  503. {
  504. return new Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>();
  505. }
  506. public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> Create<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new() where T10 : class, new() where T11 : class, new()
  507. {
  508. return new Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>();
  509. }
  510. public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> Create<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new() where T10 : class, new() where T11 : class, new() where T12 : class, new()
  511. {
  512. return new Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12>();
  513. }
  514. }
  515. }