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.

4984 lines
195 KiB

2 years ago
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Linq.Expressions;
  7. using System.Dynamic;
  8. using System.Threading.Tasks;
  9. namespace SqlSugar
  10. {
  11. #region T1
  12. public partial class QueryableProvider<T> : QueryableAccessory, ISugarQueryable<T>
  13. {
  14. public SqlSugarClient Context { get; set; }
  15. public IAdo Db { get { return Context.Ado; } }
  16. public IDbBind Bind { get { return this.Db.DbBind; } }
  17. public ISqlBuilder SqlBuilder { get; set; }
  18. public MappingTableList OldMappingTableList { get; set; }
  19. public MappingTableList QueryableMappingTableList { get; set; }
  20. public bool IsCache { get; set; }
  21. public int CacheTime { get; set; }
  22. public bool IsAs { get; set; }
  23. public QueryBuilder QueryBuilder
  24. {
  25. get
  26. {
  27. return this.SqlBuilder.QueryBuilder;
  28. }
  29. set
  30. {
  31. this.SqlBuilder.QueryBuilder = value;
  32. }
  33. }
  34. public EntityInfo EntityInfo
  35. {
  36. get
  37. {
  38. return this.Context.EntityMaintenance.GetEntityInfo<T>();
  39. }
  40. }
  41. public void Clear()
  42. {
  43. QueryBuilder.Clear();
  44. }
  45. public virtual ISugarQueryable<T> AS<T2>(string tableName)
  46. {
  47. var entityName = typeof(T2).Name;
  48. return _As(tableName, entityName);
  49. }
  50. public ISugarQueryable<T> AS(string tableName)
  51. {
  52. var entityName = typeof(T).Name;
  53. return _As(tableName, entityName);
  54. }
  55. public virtual ISugarQueryable<T> With(string withString)
  56. {
  57. QueryBuilder.TableWithString = withString;
  58. return this;
  59. }
  60. public virtual ISugarQueryable<T> Filter(string FilterName, bool isDisabledGobalFilter = false)
  61. {
  62. _Filter(FilterName, isDisabledGobalFilter);
  63. return this;
  64. }
  65. public virtual ISugarQueryable<T> AddParameters(object parameters)
  66. {
  67. if (parameters != null)
  68. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  69. return this;
  70. }
  71. public virtual ISugarQueryable<T> AddParameters(SugarParameter[] parameters)
  72. {
  73. if (parameters != null)
  74. QueryBuilder.Parameters.AddRange(parameters);
  75. return this;
  76. }
  77. public virtual ISugarQueryable<T> AddParameters(List<SugarParameter> parameters)
  78. {
  79. if (parameters != null)
  80. QueryBuilder.Parameters.AddRange(parameters);
  81. return this;
  82. }
  83. public virtual ISugarQueryable<T> AddParameters(SugarParameter parameter)
  84. {
  85. if (parameter != null)
  86. QueryBuilder.Parameters.Add(parameter);
  87. return this;
  88. }
  89. public virtual ISugarQueryable<T> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  90. {
  91. QueryBuilder.JoinIndex = +1;
  92. QueryBuilder.JoinQueryInfos
  93. .Add(new JoinQueryInfo
  94. {
  95. JoinIndex = QueryBuilder.JoinIndex,
  96. TableName = tableName,
  97. ShortName = shortName,
  98. JoinType = type,
  99. JoinWhere = joinWhere
  100. });
  101. return this;
  102. }
  103. public virtual ISugarQueryable<T> Where(Expression<Func<T, bool>> expression)
  104. {
  105. this._Where(expression);
  106. return this;
  107. }
  108. public virtual ISugarQueryable<T> Where(string whereString, object whereObj = null)
  109. {
  110. if (whereString.HasValue())
  111. this.Where<T>(whereString, whereObj);
  112. return this;
  113. }
  114. public virtual ISugarQueryable<T> Where(List<IConditionalModel> conditionalModels)
  115. {
  116. if (conditionalModels.IsNullOrEmpty()) return this;
  117. var sqlObj = this.Context.Utilities.ConditionalModelToSql(conditionalModels);
  118. return this.Where(sqlObj.Key, sqlObj.Value);
  119. }
  120. public virtual ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null)
  121. {
  122. var whereValue = QueryBuilder.WhereInfos;
  123. whereValue.Add(SqlBuilder.AppendWhereOrAnd(whereValue.Count == 0, whereString + UtilConstants.Space));
  124. if (whereObj != null)
  125. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(whereObj));
  126. return this;
  127. }
  128. public virtual ISugarQueryable<T> Having(Expression<Func<T, bool>> expression)
  129. {
  130. this._Having(expression);
  131. return this;
  132. }
  133. public virtual ISugarQueryable<T> Having(string whereString, object parameters = null)
  134. {
  135. QueryBuilder.HavingInfos = SqlBuilder.AppendHaving(whereString);
  136. if (parameters != null)
  137. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  138. return this;
  139. }
  140. public virtual ISugarQueryable<T> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  141. {
  142. if (!isWhere) return this;
  143. _Where(expression);
  144. return this;
  145. }
  146. public virtual ISugarQueryable<T> WhereIF(bool isWhere, string whereString, object whereObj = null)
  147. {
  148. if (!isWhere) return this;
  149. this.Where<T>(whereString, whereObj);
  150. return this;
  151. }
  152. public virtual T InSingle(object pkValue)
  153. {
  154. var list = In(pkValue).ToList();
  155. if (list == null) return default(T);
  156. else return list.SingleOrDefault();
  157. }
  158. public virtual ISugarQueryable<T> In<TParamter>(params TParamter[] pkValues)
  159. {
  160. if (pkValues == null || pkValues.Length == 0)
  161. {
  162. Where(SqlBuilder.SqlFalse);
  163. return this;
  164. }
  165. var pks = GetPrimaryKeys().Select(it => SqlBuilder.GetTranslationTableName(it)).ToList();
  166. Check.Exception(pks == null || pks.Count != 1, "Queryable.In(params object[] pkValues): Only one primary key");
  167. var filed = pks.FirstOrDefault();
  168. var shortName = QueryBuilder.TableShortName == null ? null : (QueryBuilder.TableShortName + ".");
  169. filed = shortName + filed;
  170. return In(filed, pkValues);
  171. }
  172. public virtual ISugarQueryable<T> In<FieldType>(string filed, params FieldType[] inValues)
  173. {
  174. if (inValues.Length == 1)
  175. {
  176. if (inValues.GetType().IsArray)
  177. {
  178. var whereIndex = QueryBuilder.WhereIndex;
  179. var parameterName = this.SqlBuilder.SqlParameterKeyWord + "InPara" + whereIndex;
  180. this.AddParameters(new SugarParameter(parameterName, inValues[0]));
  181. this.Where(string.Format(QueryBuilder.InTemplate, filed, parameterName));
  182. QueryBuilder.WhereIndex++;
  183. }
  184. else
  185. {
  186. var values = new List<object>();
  187. foreach (var item in ((IEnumerable)inValues[0]))
  188. {
  189. if (item != null)
  190. {
  191. values.Add(item.ToString().ToSqlValue());
  192. }
  193. }
  194. this.Where(string.Format(QueryBuilder.InTemplate, filed, string.Join(",", values)));
  195. }
  196. }
  197. else
  198. {
  199. var values = new List<object>();
  200. foreach (var item in inValues)
  201. {
  202. if (item != null)
  203. {
  204. values.Add(item.ToString().ToSqlValue());
  205. }
  206. }
  207. this.Where(string.Format(QueryBuilder.InTemplate, filed, string.Join(",", values)));
  208. }
  209. return this;
  210. }
  211. public virtual ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  212. {
  213. var isSingle = QueryBuilder.IsSingle();
  214. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  215. var fieldName = lamResult.GetResultString();
  216. return In(fieldName, inValues);
  217. }
  218. public virtual ISugarQueryable<T> In<TParamter>(List<TParamter> pkValues)
  219. {
  220. if (pkValues == null || pkValues.Count == 0)
  221. {
  222. Where(SqlBuilder.SqlFalse);
  223. return this;
  224. }
  225. return In(pkValues.ToArray());
  226. }
  227. public virtual ISugarQueryable<T> In<FieldType>(string InFieldName, List<FieldType> inValues)
  228. {
  229. if (inValues == null || inValues.Count == 0)
  230. {
  231. Where(SqlBuilder.SqlFalse);
  232. return this;
  233. }
  234. return In(InFieldName, inValues.ToArray());
  235. }
  236. public virtual ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  237. {
  238. if (inValues == null || inValues.Count == 0)
  239. {
  240. Where(SqlBuilder.SqlFalse);
  241. return this;
  242. }
  243. return In(expression, inValues.ToArray());
  244. }
  245. public virtual ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  246. {
  247. var sqlObj = childQueryExpression.ToSql();
  248. _InQueryable(expression, sqlObj);
  249. return this;
  250. }
  251. public virtual ISugarQueryable<T> OrderBy(string orderFileds, string orderType = "")
  252. {
  253. var orderByValue = QueryBuilder.OrderByValue;
  254. if (QueryBuilder.OrderByValue.IsNullOrEmpty())
  255. {
  256. QueryBuilder.OrderByValue = QueryBuilder.OrderByTemplate;
  257. }
  258. QueryBuilder.OrderByValue += string.IsNullOrEmpty(orderByValue) ? orderFileds : ("," + orderFileds);
  259. QueryBuilder.OrderByValue += " " + orderType;
  260. return this;
  261. }
  262. public virtual ISugarQueryable<T> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  263. {
  264. this._OrderBy(expression, type);
  265. return this;
  266. }
  267. public virtual ISugarQueryable<T> GroupBy(Expression<Func<T, object>> expression)
  268. {
  269. _GroupBy(expression);
  270. return this;
  271. }
  272. public virtual ISugarQueryable<T> OrderByIF(bool isOrderBy, string orderFileds)
  273. {
  274. if (isOrderBy)
  275. return this.OrderBy(orderFileds);
  276. else
  277. return this;
  278. }
  279. public virtual ISugarQueryable<T> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  280. {
  281. if (isOrderBy)
  282. return this.OrderBy(expression, type);
  283. else
  284. return this;
  285. }
  286. public virtual ISugarQueryable<T> GroupBy(string groupFileds)
  287. {
  288. var croupByValue = QueryBuilder.GroupByValue;
  289. if (QueryBuilder.GroupByValue.IsNullOrEmpty())
  290. {
  291. QueryBuilder.GroupByValue = QueryBuilder.GroupByTemplate;
  292. }
  293. QueryBuilder.GroupByValue += string.IsNullOrEmpty(croupByValue) ? groupFileds : ("," + groupFileds);
  294. return this;
  295. }
  296. public virtual ISugarQueryable<T> PartitionBy(Expression<Func<T, object>> expression)
  297. {
  298. if (QueryBuilder.Take == null)
  299. QueryBuilder.Take = 1;
  300. _PartitionBy(expression);
  301. return this;
  302. }
  303. public virtual ISugarQueryable<T> PartitionBy(string groupFileds)
  304. {
  305. var partitionByValue = QueryBuilder.PartitionByValue;
  306. if (QueryBuilder.PartitionByValue.IsNullOrEmpty())
  307. {
  308. QueryBuilder.PartitionByValue = QueryBuilder.PartitionByTemplate;
  309. }
  310. QueryBuilder.PartitionByValue += string.IsNullOrEmpty(partitionByValue) ? groupFileds : ("," + groupFileds);
  311. return this;
  312. }
  313. public virtual ISugarQueryable<T> Skip(int num)
  314. {
  315. QueryBuilder.Skip = num;
  316. return this;
  317. }
  318. public virtual ISugarQueryable<T> Take(int num)
  319. {
  320. QueryBuilder.Take = num;
  321. return this;
  322. }
  323. public virtual T Single()
  324. {
  325. if (QueryBuilder.OrderByValue.IsNullOrEmpty())
  326. {
  327. QueryBuilder.OrderByValue = QueryBuilder.DefaultOrderByTemplate;
  328. }
  329. var oldSkip = QueryBuilder.Skip;
  330. var oldTake = QueryBuilder.Take;
  331. var oldOrderBy = QueryBuilder.OrderByValue;
  332. QueryBuilder.Skip = null;
  333. QueryBuilder.Take = null;
  334. QueryBuilder.OrderByValue = null;
  335. var result = this.ToList();
  336. QueryBuilder.Skip = oldSkip;
  337. QueryBuilder.Take = oldTake;
  338. QueryBuilder.OrderByValue = oldOrderBy;
  339. if (result == null || result.Count == 0)
  340. {
  341. return default(T);
  342. }
  343. else if (result.Count == 2)
  344. {
  345. Check.Exception(true, ".Single() result must not exceed one . You can use.First()");
  346. return default(T);
  347. }
  348. else
  349. {
  350. return result.SingleOrDefault();
  351. }
  352. }
  353. public virtual T Single(Expression<Func<T, bool>> expression)
  354. {
  355. _Where(expression);
  356. var result = Single();
  357. this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
  358. return result;
  359. }
  360. public virtual T First()
  361. {
  362. if (QueryBuilder.OrderByValue.IsNullOrEmpty())
  363. {
  364. QueryBuilder.OrderByValue = QueryBuilder.DefaultOrderByTemplate;
  365. }
  366. if (QueryBuilder.Skip.HasValue)
  367. {
  368. QueryBuilder.Take = 1;
  369. return this.ToList().FirstOrDefault();
  370. }
  371. else
  372. {
  373. QueryBuilder.Skip = 0;
  374. QueryBuilder.Take = 1;
  375. var result = this.ToList();
  376. if (result.HasValue())
  377. return result.FirstOrDefault();
  378. else
  379. return default(T);
  380. }
  381. }
  382. public virtual T First(Expression<Func<T, bool>> expression)
  383. {
  384. _Where(expression);
  385. var result = First();
  386. this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
  387. return result;
  388. }
  389. public virtual bool Any(Expression<Func<T, bool>> expression)
  390. {
  391. _Where(expression);
  392. var result = Any();
  393. this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
  394. return result;
  395. }
  396. public virtual bool Any()
  397. {
  398. return this.Count() > 0;
  399. }
  400. public virtual ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression)
  401. {
  402. return _Select<TResult>(expression);
  403. }
  404. public virtual ISugarQueryable<TResult> Select<TResult>(string selectValue)
  405. {
  406. var result = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig);
  407. result.Context = this.Context;
  408. result.SqlBuilder = this.SqlBuilder;
  409. QueryBuilder.SelectValue = selectValue;
  410. return result;
  411. }
  412. public virtual ISugarQueryable<T> Select(string selectValue)
  413. {
  414. QueryBuilder.SelectValue = selectValue;
  415. return this;
  416. }
  417. public virtual ISugarQueryable<T> MergeTable()
  418. {
  419. Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Queryable.Select Method .");
  420. Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0 || this.QueryBuilder.OrderByValue.HasValue(), "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
  421. ToSqlBefore();
  422. var sql = QueryBuilder.ToSqlString();
  423. var tableName = this.SqlBuilder.GetPackTable(sql, nameof(MergeTable));
  424. var mergeQueryable = this.Context.Queryable<ExpandoObject>();
  425. mergeQueryable.QueryBuilder.Parameters = QueryBuilder.Parameters;
  426. mergeQueryable.QueryBuilder.WhereIndex = QueryBuilder.WhereIndex + 1;
  427. mergeQueryable.QueryBuilder.JoinIndex = QueryBuilder.JoinIndex + 1;
  428. mergeQueryable.QueryBuilder.LambdaExpressions.ParameterIndex = QueryBuilder.LambdaExpressions.ParameterIndex;
  429. return mergeQueryable.AS(tableName).Select<T>("*");
  430. }
  431. public virtual int Count()
  432. {
  433. InitMapping();
  434. QueryBuilder.IsCount = true;
  435. var result = 0;
  436. if (IsCache)
  437. {
  438. var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
  439. result = CacheSchemeMain.GetOrCreate<int>(cacheService, this.QueryBuilder, () => { return GetCount(); }, CacheTime, this.Context);
  440. }
  441. else
  442. {
  443. result = GetCount();
  444. }
  445. RestoreMapping();
  446. QueryBuilder.IsCount = false;
  447. return result;
  448. }
  449. public virtual int Count(Expression<Func<T, bool>> expression)
  450. {
  451. _Where(expression);
  452. var result = Count();
  453. this.QueryBuilder.WhereInfos.Remove(this.QueryBuilder.WhereInfos.Last());
  454. return result;
  455. }
  456. public virtual TResult Max<TResult>(string maxField)
  457. {
  458. this.Select(string.Format(QueryBuilder.MaxTemplate, maxField));
  459. var result = this._ToList<TResult>().SingleOrDefault();
  460. return result;
  461. }
  462. public virtual TResult Max<TResult>(Expression<Func<T, TResult>> expression)
  463. {
  464. return _Max<TResult>(expression);
  465. }
  466. public virtual TResult Min<TResult>(string minField)
  467. {
  468. this.Select(string.Format(QueryBuilder.MinTemplate, minField));
  469. var result = this._ToList<TResult>().SingleOrDefault();
  470. return result;
  471. }
  472. public virtual TResult Min<TResult>(Expression<Func<T, TResult>> expression)
  473. {
  474. return _Min<TResult>(expression);
  475. }
  476. public virtual TResult Sum<TResult>(string sumField)
  477. {
  478. this.Select(string.Format(QueryBuilder.SumTemplate, sumField));
  479. var result = this._ToList<TResult>().SingleOrDefault();
  480. return result;
  481. }
  482. public virtual TResult Sum<TResult>(Expression<Func<T, TResult>> expression)
  483. {
  484. return _Sum<TResult>(expression);
  485. }
  486. public virtual TResult Avg<TResult>(string avgField)
  487. {
  488. this.Select(string.Format(QueryBuilder.AvgTemplate, avgField));
  489. var result = this._ToList<TResult>().SingleOrDefault();
  490. return result;
  491. }
  492. public virtual TResult Avg<TResult>(Expression<Func<T, TResult>> expression)
  493. {
  494. return _Avg<TResult>(expression);
  495. }
  496. public virtual string ToJson()
  497. {
  498. return this.Context.Utilities.SerializeObject(this.ToList());
  499. }
  500. public virtual string ToJsonPage(int pageIndex, int pageSize)
  501. {
  502. return this.Context.Utilities.SerializeObject(this.ToPageList(pageIndex, pageSize));
  503. }
  504. public virtual string ToJsonPage(int pageIndex, int pageSize, ref int totalNumber)
  505. {
  506. return this.Context.Utilities.SerializeObject(this.ToPageList(pageIndex, pageSize, ref totalNumber));
  507. }
  508. public virtual DataTable ToDataTable()
  509. {
  510. InitMapping();
  511. var sqlObj = this.ToSql();
  512. RestoreMapping();
  513. var result = this.Db.GetDataTable(sqlObj.Key, sqlObj.Value.ToArray());
  514. return result;
  515. }
  516. public virtual DataTable ToDataTablePage(int pageIndex, int pageSize)
  517. {
  518. if (pageIndex == 0)
  519. pageIndex = 1;
  520. if (QueryBuilder.PartitionByValue.HasValue())
  521. {
  522. QueryBuilder.ExternalPageIndex = pageIndex;
  523. QueryBuilder.ExternalPageSize = pageSize;
  524. }
  525. else
  526. {
  527. QueryBuilder.Skip = (pageIndex - 1) * pageSize;
  528. QueryBuilder.Take = pageSize;
  529. }
  530. return ToDataTable();
  531. }
  532. public virtual DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber)
  533. {
  534. _RestoreMapping = false;
  535. totalNumber = this.Count();
  536. var result = ToDataTablePage(pageIndex, pageSize);
  537. _RestoreMapping = true;
  538. return result;
  539. }
  540. public virtual List<T> ToList()
  541. {
  542. InitMapping();
  543. return _ToList<T>();
  544. }
  545. public virtual List<T> ToPageList(int pageIndex, int pageSize)
  546. {
  547. if (pageIndex == 0)
  548. pageIndex = 1;
  549. if (QueryBuilder.PartitionByValue.HasValue())
  550. {
  551. QueryBuilder.ExternalPageIndex = pageIndex;
  552. QueryBuilder.ExternalPageSize = pageSize;
  553. }
  554. else
  555. {
  556. QueryBuilder.Skip = (pageIndex - 1) * pageSize;
  557. QueryBuilder.Take = pageSize;
  558. }
  559. return ToList();
  560. }
  561. public virtual List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber)
  562. {
  563. _RestoreMapping = false;
  564. List<T> result = null;
  565. var count = this.Count();
  566. QueryBuilder.IsDisabledGobalFilter = UtilMethods.GetOldValue(QueryBuilder.IsDisabledGobalFilter, () =>
  567. {
  568. QueryBuilder.IsDisabledGobalFilter = true;
  569. result = count == 0 ? new List<T>() : ToPageList(pageIndex, pageSize);
  570. });
  571. totalNumber = count;
  572. _RestoreMapping = true;
  573. return result;
  574. }
  575. public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
  576. {
  577. InitMapping();
  578. ToSqlBefore();
  579. var sql = QueryBuilder.ToSqlString();
  580. RestoreMapping();
  581. return new KeyValuePair<string, List<SugarParameter>>(sql, QueryBuilder.Parameters);
  582. }
  583. public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
  584. {
  585. Check.ArgumentNullException(this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService, "Use Cache ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is required ");
  586. this.IsCache = true;
  587. this.CacheTime = cacheDurationInSeconds;
  588. return this;
  589. }
  590. public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  591. {
  592. if (IsCache)
  593. {
  594. this.IsCache = true;
  595. this.CacheTime = cacheDurationInSeconds;
  596. }
  597. return this;
  598. }
  599. public string ToClassString(string className)
  600. {
  601. var columns = new List<DbColumnInfo>();
  602. var properties = typeof(T).GetProperties();
  603. foreach (var item in properties)
  604. {
  605. columns.Add(new DbColumnInfo
  606. {
  607. DbColumnName = item.Name,
  608. PropertyName = UtilMethods.GetUnderType(item.PropertyType).Name,
  609. PropertyType = UtilMethods.GetUnderType(item.PropertyType)
  610. });
  611. }
  612. var result = ((this.Context.DbFirst) as DbFirstProvider).GetClassString(columns, ref className);
  613. return result;
  614. }
  615. #region Async methods
  616. public Task<T> SingleAsync()
  617. {
  618. var result = new Task<T>(() =>
  619. {
  620. var asyncQueryable = CopyQueryable();
  621. return asyncQueryable.Single();
  622. });
  623. TaskStart(result);
  624. return result;
  625. }
  626. public Task<T> SingleAsync(Expression<Func<T, bool>> expression)
  627. {
  628. var result = new Task<T>(() =>
  629. {
  630. var asyncQueryable = CopyQueryable();
  631. return asyncQueryable.Single(expression);
  632. });
  633. TaskStart(result);
  634. return result;
  635. }
  636. public Task<T> FirstAsync()
  637. {
  638. var result = new Task<T>(() =>
  639. {
  640. var asyncQueryable = CopyQueryable();
  641. return asyncQueryable.First();
  642. });
  643. TaskStart(result);
  644. return result;
  645. }
  646. public Task<T> FirstAsync(Expression<Func<T, bool>> expression)
  647. {
  648. var result = new Task<T>(() =>
  649. {
  650. var asyncQueryable = CopyQueryable();
  651. return asyncQueryable.First(expression);
  652. });
  653. TaskStart(result);
  654. return result;
  655. }
  656. public Task<bool> AnyAsync(Expression<Func<T, bool>> expression)
  657. {
  658. var result = new Task<bool>(() =>
  659. {
  660. var asyncQueryable = CopyQueryable();
  661. return asyncQueryable.Any(expression);
  662. });
  663. TaskStart(result);
  664. return result;
  665. }
  666. public Task<bool> AnyAsync()
  667. {
  668. var result = new Task<bool>(() =>
  669. {
  670. var asyncQueryable = CopyQueryable();
  671. return asyncQueryable.Any();
  672. });
  673. TaskStart(result);
  674. return result;
  675. }
  676. public Task<int> CountAsync()
  677. {
  678. var result = new Task<int>(() =>
  679. {
  680. var asyncQueryable = CopyQueryable();
  681. return asyncQueryable.Count();
  682. });
  683. TaskStart(result);
  684. return result;
  685. }
  686. public Task<int> CountAsync(Expression<Func<T, bool>> expression)
  687. {
  688. var result = new Task<int>(() =>
  689. {
  690. var asyncQueryable = CopyQueryable();
  691. return asyncQueryable.Count(expression);
  692. });
  693. TaskStart(result); ;
  694. return result;
  695. }
  696. public Task<TResult> MaxAsync<TResult>(string maxField)
  697. {
  698. var result = new Task<TResult>(() =>
  699. {
  700. var asyncQueryable = CopyQueryable();
  701. return asyncQueryable.Max<TResult>(maxField);
  702. });
  703. TaskStart(result);
  704. return result;
  705. }
  706. public Task<TResult> MaxAsync<TResult>(Expression<Func<T, TResult>> expression)
  707. {
  708. var result = new Task<TResult>(() =>
  709. {
  710. var asyncQueryable = CopyQueryable();
  711. return asyncQueryable.Max<TResult>(expression);
  712. });
  713. TaskStart(result);
  714. return result;
  715. }
  716. public Task<TResult> MinAsync<TResult>(string minField)
  717. {
  718. var result = new Task<TResult>(() =>
  719. {
  720. var asyncQueryable = CopyQueryable();
  721. return asyncQueryable.Min<TResult>(minField);
  722. });
  723. TaskStart(result);
  724. return result;
  725. }
  726. public Task<TResult> MinAsync<TResult>(Expression<Func<T, TResult>> expression)
  727. {
  728. var result = new Task<TResult>(() =>
  729. {
  730. var asyncQueryable = CopyQueryable();
  731. return asyncQueryable.Min<TResult>(expression);
  732. });
  733. TaskStart(result);
  734. return result;
  735. }
  736. public Task<TResult> SumAsync<TResult>(string sumField)
  737. {
  738. var result = new Task<TResult>(() =>
  739. {
  740. var asyncQueryable = CopyQueryable();
  741. return asyncQueryable.Sum<TResult>(sumField);
  742. });
  743. TaskStart(result);
  744. return result;
  745. }
  746. public Task<TResult> SumAsync<TResult>(Expression<Func<T, TResult>> expression)
  747. {
  748. var result = new Task<TResult>(() =>
  749. {
  750. var asyncQueryable = CopyQueryable();
  751. return asyncQueryable.Sum<TResult>(expression);
  752. });
  753. TaskStart(result);
  754. return result;
  755. }
  756. public Task<TResult> AvgAsync<TResult>(string avgField)
  757. {
  758. var result = new Task<TResult>(() =>
  759. {
  760. var asyncQueryable = CopyQueryable();
  761. return asyncQueryable.Avg<TResult>(avgField);
  762. });
  763. TaskStart(result);
  764. return result;
  765. }
  766. public Task<TResult> AvgAsync<TResult>(Expression<Func<T, TResult>> expression)
  767. {
  768. var result = new Task<TResult>(() =>
  769. {
  770. var asyncQueryable = CopyQueryable();
  771. return asyncQueryable.Avg<TResult>(expression);
  772. });
  773. TaskStart(result);
  774. return result;
  775. }
  776. public Task<List<T>> ToListAsync()
  777. {
  778. var result = new Task<List<T>>(() =>
  779. {
  780. var asyncQueryable = CopyQueryable();
  781. return asyncQueryable.ToList();
  782. });
  783. TaskStart(result);
  784. return result;
  785. }
  786. public Task<string> ToJsonAsync()
  787. {
  788. var result = new Task<string>(() =>
  789. {
  790. var asyncQueryable = CopyQueryable();
  791. return asyncQueryable.ToJson();
  792. });
  793. TaskStart(result);
  794. return result;
  795. }
  796. public Task<string> ToJsonPageAsync(int pageIndex, int pageSize)
  797. {
  798. var result = new Task<string>(() =>
  799. {
  800. var asyncQueryable = CopyQueryable();
  801. return asyncQueryable.ToJsonPage(pageIndex, pageSize);
  802. });
  803. TaskStart(result);
  804. return result;
  805. }
  806. public Task<KeyValuePair<string, int>> ToJsonPageAsync(int pageIndex, int pageSize, int totalNumber)
  807. {
  808. var result = new Task<KeyValuePair<string, int>>(() =>
  809. {
  810. var totalNumberAsync = 0;
  811. var asyncQueryable = CopyQueryable();
  812. var list = asyncQueryable.ToJsonPage(pageIndex, pageSize, ref totalNumberAsync);
  813. return new KeyValuePair<string, int>(list, totalNumberAsync);
  814. });
  815. TaskStart(result);
  816. return result;
  817. }
  818. public Task<DataTable> ToDataTableAsync()
  819. {
  820. var result = new Task<DataTable>(() =>
  821. {
  822. var asyncQueryable = CopyQueryable();
  823. return asyncQueryable.ToDataTable();
  824. });
  825. TaskStart(result);
  826. return result;
  827. }
  828. public Task<DataTable> ToDataTablePageAsync(int pageIndex, int pageSize)
  829. {
  830. var result = new Task<DataTable>(() =>
  831. {
  832. var asyncQueryable = CopyQueryable();
  833. return asyncQueryable.ToDataTablePage(pageIndex, pageSize);
  834. });
  835. TaskStart(result);
  836. return result;
  837. }
  838. public Task<KeyValuePair<DataTable, int>> ToDataTablePageAsync(int pageIndex, int pageSize, int totalNumber)
  839. {
  840. var result = new Task<KeyValuePair<DataTable, int>>(() =>
  841. {
  842. var totalNumberAsync = 0;
  843. var asyncQueryable = CopyQueryable();
  844. var list = asyncQueryable.ToDataTablePage(pageIndex, pageSize, ref totalNumberAsync);
  845. return new KeyValuePair<DataTable, int>(list, totalNumberAsync);
  846. });
  847. TaskStart(result);
  848. return result;
  849. }
  850. public Task<List<T>> ToPageListAsync(int pageIndex, int pageSize)
  851. {
  852. var result = new Task<List<T>>(() =>
  853. {
  854. var asyncQueryable = CopyQueryable();
  855. return asyncQueryable.ToPageList(pageIndex, pageSize);
  856. });
  857. TaskStart(result);
  858. return result;
  859. }
  860. public Task<KeyValuePair<List<T>, int>> ToPageListAsync(int pageIndex, int pageSize, int totalNumber)
  861. {
  862. var result = new Task<KeyValuePair<List<T>, int>>(() =>
  863. {
  864. var totalNumberAsync = 0;
  865. var asyncQueryable = CopyQueryable();
  866. var list = asyncQueryable.ToPageList(pageIndex, pageSize, ref totalNumberAsync);
  867. return new KeyValuePair<List<T>, int>(list, totalNumberAsync);
  868. });
  869. TaskStart(result);
  870. return result;
  871. }
  872. #endregion
  873. #region Private Methods
  874. private void TaskStart<Type>(Task<Type> result)
  875. {
  876. if (this.Context.CurrentConnectionConfig.IsShardSameThread)
  877. {
  878. Check.Exception(true, "IsShardSameThread=true can't be used async method");
  879. }
  880. result.Start();
  881. }
  882. protected ISugarQueryable<TResult> _Select<TResult>(Expression expression)
  883. {
  884. var result = InstanceFactory.GetQueryable<TResult>(this.Context.CurrentConnectionConfig);
  885. result.Context = this.Context;
  886. result.SqlBuilder = this.SqlBuilder;
  887. result.SqlBuilder.QueryBuilder.Parameters = QueryBuilder.Parameters;
  888. result.SqlBuilder.QueryBuilder.SelectValue = expression;
  889. return result;
  890. }
  891. protected void _Where(Expression expression)
  892. {
  893. var isSingle = QueryBuilder.IsSingle();
  894. var result = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple);
  895. QueryBuilder.WhereInfos.Add(SqlBuilder.AppendWhereOrAnd(QueryBuilder.WhereInfos.IsNullOrEmpty(), result.GetResultString()));
  896. }
  897. protected ISugarQueryable<T> _OrderBy(Expression expression, OrderByType type = OrderByType.Asc)
  898. {
  899. var isSingle = QueryBuilder.IsSingle();
  900. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  901. OrderBy(lamResult.GetResultString() + UtilConstants.Space + type.ToString().ToUpper());
  902. return this;
  903. }
  904. protected ISugarQueryable<T> _GroupBy(Expression expression)
  905. {
  906. var lambda = expression as LambdaExpression;
  907. expression = lambda.Body;
  908. var isSingle = QueryBuilder.IsSingle();
  909. ExpressionResult lamResult = null;
  910. string result = null;
  911. if (expression is NewExpression)
  912. {
  913. lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.ArraySingle : ResolveExpressType.ArrayMultiple);
  914. result = string.Join(",", lamResult.GetResultArray().Select(it => it));
  915. }
  916. else
  917. {
  918. lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  919. result = lamResult.GetResultString();
  920. }
  921. GroupBy(result);
  922. return this;
  923. }
  924. protected TResult _Min<TResult>(Expression expression)
  925. {
  926. var isSingle = QueryBuilder.IsSingle();
  927. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  928. return Min<TResult>(lamResult.GetResultString());
  929. }
  930. protected TResult _Avg<TResult>(Expression expression)
  931. {
  932. var isSingle = QueryBuilder.IsSingle();
  933. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  934. return Avg<TResult>(lamResult.GetResultString());
  935. }
  936. protected TResult _Max<TResult>(Expression expression)
  937. {
  938. var isSingle = QueryBuilder.IsSingle();
  939. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  940. return Max<TResult>(lamResult.GetResultString());
  941. }
  942. protected TResult _Sum<TResult>(Expression expression)
  943. {
  944. var isSingle = QueryBuilder.IsSingle();
  945. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  946. return Sum<TResult>(lamResult.GetResultString());
  947. }
  948. protected ISugarQueryable<T> _As(string tableName, string entityName)
  949. {
  950. IsAs = true;
  951. OldMappingTableList = this.Context.MappingTables;
  952. this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
  953. this.Context.MappingTables.Add(entityName, tableName);
  954. this.QueryableMappingTableList = this.Context.MappingTables;
  955. return this;
  956. }
  957. protected void _Filter(string FilterName, bool isDisabledGobalFilter)
  958. {
  959. QueryBuilder.IsDisabledGobalFilter = isDisabledGobalFilter;
  960. if (this.Context.QueryFilter.GeFilterList.HasValue() && FilterName.HasValue())
  961. {
  962. var list = this.Context.QueryFilter.GeFilterList.Where(it => it.FilterName == FilterName && it.IsJoinQuery == !QueryBuilder.IsSingle());
  963. foreach (var item in list)
  964. {
  965. var filterResult = item.FilterValue(this.Context);
  966. Where(filterResult.Sql, filterResult.Parameters);
  967. }
  968. }
  969. }
  970. public ISugarQueryable<T> _PartitionBy(Expression expression)
  971. {
  972. var lambda = expression as LambdaExpression;
  973. expression = lambda.Body;
  974. var isSingle = QueryBuilder.IsSingle();
  975. ExpressionResult lamResult = null;
  976. string result = null;
  977. if (expression is NewExpression)
  978. {
  979. lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.ArraySingle : ResolveExpressType.ArrayMultiple);
  980. result = string.Join(",", lamResult.GetResultArray());
  981. }
  982. else
  983. {
  984. lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  985. result = lamResult.GetResultString();
  986. }
  987. PartitionBy(result);
  988. return this;
  989. }
  990. protected ISugarQueryable<T> _Having(Expression expression)
  991. {
  992. var isSingle = QueryBuilder.IsSingle();
  993. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple);
  994. Having(lamResult.GetResultString());
  995. return this;
  996. }
  997. protected List<TResult> _ToList<TResult>()
  998. {
  999. List<TResult> result = null;
  1000. var sqlObj = this.ToSql();
  1001. if (IsCache)
  1002. {
  1003. var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
  1004. result = CacheSchemeMain.GetOrCreate<List<TResult>>(cacheService, this.QueryBuilder, () => { return GetData<TResult>(sqlObj); }, CacheTime, this.Context);
  1005. }
  1006. else
  1007. {
  1008. result = GetData<TResult>(sqlObj);
  1009. }
  1010. RestoreMapping();
  1011. return result;
  1012. }
  1013. protected int GetCount()
  1014. {
  1015. var sql = string.Empty;
  1016. ToSqlBefore();
  1017. sql = QueryBuilder.ToSqlString();
  1018. sql = QueryBuilder.ToCountSql(sql);
  1019. var result = Context.Ado.GetInt(sql, QueryBuilder.Parameters.ToArray());
  1020. return result;
  1021. }
  1022. private void ToSqlBefore()
  1023. {
  1024. var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
  1025. if (moreSetts != null && moreSetts.IsWithNoLockQuery && string.IsNullOrEmpty(QueryBuilder.TableWithString))
  1026. {
  1027. this.With(SqlWith.NoLock);
  1028. }
  1029. }
  1030. protected List<TResult> GetData<TResult>(KeyValuePair<string, List<SugarParameter>> sqlObj)
  1031. {
  1032. List<TResult> result;
  1033. var isComplexModel = QueryBuilder.IsComplexModel(sqlObj.Key);
  1034. var entityType = typeof(TResult);
  1035. var dataReader = this.Db.GetDataReader(sqlObj.Key, sqlObj.Value.ToArray());
  1036. if (entityType == UtilConstants.DynamicType)
  1037. {
  1038. result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List<TResult>;
  1039. }
  1040. else if (entityType == UtilConstants.ObjType)
  1041. {
  1042. result = this.Context.Utilities.DataReaderToExpandoObjectList(dataReader).Select(it => ((TResult)(object)it)).ToList();
  1043. }
  1044. else result = entityType.IsAnonymousType() || isComplexModel ? this.Context.Utilities.DataReaderToDynamicList<TResult>(dataReader) : this.Bind.DataReaderToList<TResult>(entityType, dataReader);
  1045. SetContextModel(result, entityType);
  1046. return result;
  1047. }
  1048. protected void _InQueryable(Expression<Func<T, object>> expression, KeyValuePair<string, List<SugarParameter>> sqlObj)
  1049. {
  1050. var sql = sqlObj.Key;
  1051. if (sqlObj.Value.HasValue())
  1052. {
  1053. this.SqlBuilder.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), 100);
  1054. this.QueryBuilder.Parameters.AddRange(sqlObj.Value);
  1055. }
  1056. var isSingle = QueryBuilder.IsSingle();
  1057. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1058. var fieldName = lamResult.GetResultString();
  1059. var whereSql = string.Format(this.QueryBuilder.InTemplate, fieldName, sql);
  1060. this.QueryBuilder.WhereInfos.Add(SqlBuilder.AppendWhereOrAnd(this.QueryBuilder.WhereInfos.IsNullOrEmpty(), whereSql));
  1061. base._InQueryableIndex += 100;
  1062. }
  1063. protected List<string> GetPrimaryKeys()
  1064. {
  1065. if (this.Context.IsSystemTablesConfig)
  1066. {
  1067. return this.Context.DbMaintenance.GetPrimaries(this.Context.EntityMaintenance.GetTableName(this.EntityInfo.EntityName));
  1068. }
  1069. else
  1070. {
  1071. return this.EntityInfo.Columns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName).ToList();
  1072. }
  1073. }
  1074. protected virtual List<string> GetIdentityKeys()
  1075. {
  1076. if (this.Context.IsSystemTablesConfig)
  1077. {
  1078. return this.Context.DbMaintenance.GetIsIdentities(this.EntityInfo.DbTableName);
  1079. }
  1080. else
  1081. {
  1082. return this.EntityInfo.Columns.Where(it => it.IsIdentity).Select(it => it.DbColumnName).ToList();
  1083. }
  1084. }
  1085. protected void RestoreMapping()
  1086. {
  1087. if (IsAs && _RestoreMapping)
  1088. {
  1089. this.Context.MappingTables = OldMappingTableList == null ? new MappingTableList() : OldMappingTableList;
  1090. }
  1091. }
  1092. protected void InitMapping()
  1093. {
  1094. if (this.QueryableMappingTableList != null)
  1095. this.Context.MappingTables = this.QueryableMappingTableList;
  1096. }
  1097. private void SetContextModel<TResult>(List<TResult> result, Type entityType)
  1098. {
  1099. if (result.HasValue())
  1100. {
  1101. if (entityType.GetTypeInfo().BaseType.HasValue() && entityType.GetTypeInfo().BaseType == UtilConstants.ModelType)
  1102. {
  1103. foreach (var item in result)
  1104. {
  1105. var contextProperty = item.GetType().GetProperty(nameof(Context));
  1106. var newClient = this.Context.Utilities.CopyContext();
  1107. contextProperty.SetValue(item, newClient, null);
  1108. }
  1109. }
  1110. }
  1111. }
  1112. private ISugarQueryable<T> CopyQueryable()
  1113. {
  1114. var asyncContext = this.Context.Utilities.CopyContext(true);
  1115. asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
  1116. var asyncQueryable = asyncContext.Queryable<ExpandoObject>().Select<T>(string.Empty);
  1117. var asyncQueryableBuilder = asyncQueryable.QueryBuilder;
  1118. asyncQueryableBuilder.Take = this.QueryBuilder.Take;
  1119. asyncQueryableBuilder.Skip = this.QueryBuilder.Skip;
  1120. asyncQueryableBuilder.SelectValue = this.QueryBuilder.SelectValue;
  1121. asyncQueryableBuilder.WhereInfos = this.QueryBuilder.WhereInfos;
  1122. asyncQueryableBuilder.EasyJoinInfos = this.QueryBuilder.EasyJoinInfos;
  1123. asyncQueryableBuilder.JoinQueryInfos = this.QueryBuilder.JoinQueryInfos;
  1124. asyncQueryableBuilder.WhereIndex = this.QueryBuilder.WhereIndex;
  1125. asyncQueryableBuilder.EntityType = this.QueryBuilder.EntityType;
  1126. asyncQueryableBuilder.EntityName = this.QueryBuilder.EntityName;
  1127. asyncQueryableBuilder.Parameters = this.QueryBuilder.Parameters;
  1128. asyncQueryableBuilder.TableShortName = this.QueryBuilder.TableShortName;
  1129. asyncQueryableBuilder.TableWithString = this.QueryBuilder.TableWithString;
  1130. asyncQueryableBuilder.GroupByValue = this.QueryBuilder.GroupByValue;
  1131. asyncQueryableBuilder.OrderByValue = this.QueryBuilder.OrderByValue;
  1132. return asyncQueryable;
  1133. }
  1134. #endregion
  1135. }
  1136. #endregion
  1137. #region T2
  1138. public partial class QueryableProvider<T, T2> : QueryableProvider<T>, ISugarQueryable<T, T2>
  1139. {
  1140. #region Where
  1141. public new ISugarQueryable<T, T2> Where(Expression<Func<T, bool>> expression)
  1142. {
  1143. _Where(expression);
  1144. return this;
  1145. }
  1146. public ISugarQueryable<T, T2> Where(Expression<Func<T, T2, bool>> expression)
  1147. {
  1148. _Where(expression);
  1149. return this;
  1150. }
  1151. public new ISugarQueryable<T, T2> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  1152. {
  1153. if (isWhere)
  1154. _Where(expression);
  1155. return this;
  1156. }
  1157. public ISugarQueryable<T, T2> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  1158. {
  1159. if (isWhere)
  1160. _Where(expression);
  1161. return this;
  1162. }
  1163. public new ISugarQueryable<T, T2> Where(string whereString, object whereObj)
  1164. {
  1165. Where<T>(whereString, whereObj);
  1166. return this;
  1167. }
  1168. public new ISugarQueryable<T, T2> Where(List<IConditionalModel> conditionalModels)
  1169. {
  1170. base.Where(conditionalModels);
  1171. return this;
  1172. }
  1173. public new ISugarQueryable<T, T2> WhereIF(bool isWhere, string whereString, object whereObj)
  1174. {
  1175. if (!isWhere) return this;
  1176. this.Where<T>(whereString, whereObj);
  1177. return this;
  1178. }
  1179. #endregion
  1180. #region Select
  1181. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  1182. {
  1183. return _Select<TResult>(expression);
  1184. }
  1185. #endregion
  1186. #region Order
  1187. public new ISugarQueryable<T, T2> OrderBy(string orderFileds, string orderType = null)
  1188. {
  1189. base.OrderBy(orderFileds, orderType);
  1190. return this;
  1191. }
  1192. public ISugarQueryable<T, T2> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  1193. {
  1194. _OrderBy(expression, type);
  1195. return this;
  1196. }
  1197. public new ISugarQueryable<T, T2> OrderBy(Expression<Func<T, object>> expression, OrderByType type)
  1198. {
  1199. _OrderBy(expression, type);
  1200. return this;
  1201. }
  1202. public new ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, string orderFileds)
  1203. {
  1204. if (isOrderBy)
  1205. base.OrderBy(orderFileds);
  1206. return this;
  1207. }
  1208. public new ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  1209. {
  1210. if (isOrderBy)
  1211. _OrderBy(expression, type);
  1212. return this;
  1213. }
  1214. public ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  1215. {
  1216. if (isOrderBy)
  1217. _OrderBy(expression, type);
  1218. return this;
  1219. }
  1220. #endregion
  1221. #region GroupBy
  1222. public new ISugarQueryable<T, T2> GroupBy(Expression<Func<T, object>> expression)
  1223. {
  1224. _GroupBy(expression);
  1225. return this;
  1226. }
  1227. public ISugarQueryable<T, T2> GroupBy(Expression<Func<T, T2, object>> expression)
  1228. {
  1229. _GroupBy(expression);
  1230. return this;
  1231. }
  1232. public new ISugarQueryable<T, T2> Having(Expression<Func<T, bool>> expression)
  1233. {
  1234. this._Having(expression);
  1235. return this;
  1236. }
  1237. public ISugarQueryable<T, T2> Having(Expression<Func<T, T2, bool>> expression)
  1238. {
  1239. this._Having(expression);
  1240. return this;
  1241. }
  1242. public new ISugarQueryable<T, T2> Having(string whereString, object whereObj)
  1243. {
  1244. base.Having(whereString, whereObj);
  1245. return this;
  1246. }
  1247. #endregion
  1248. #region Aggr
  1249. public TResult Max<TResult>(Expression<Func<T, T2, TResult>> expression)
  1250. {
  1251. return _Max<TResult>(expression);
  1252. }
  1253. public TResult Min<TResult>(Expression<Func<T, T2, TResult>> expression)
  1254. {
  1255. return _Min<TResult>(expression);
  1256. }
  1257. public TResult Sum<TResult>(Expression<Func<T, T2, TResult>> expression)
  1258. {
  1259. return _Sum<TResult>(expression);
  1260. }
  1261. public TResult Avg<TResult>(Expression<Func<T, T2, TResult>> expression)
  1262. {
  1263. return _Avg<TResult>(expression);
  1264. }
  1265. #endregion
  1266. #region In
  1267. public new ISugarQueryable<T, T2> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  1268. {
  1269. var isSingle = QueryBuilder.IsSingle();
  1270. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1271. var fieldName = lamResult.GetResultString();
  1272. In(fieldName, inValues);
  1273. return this;
  1274. }
  1275. public new ISugarQueryable<T, T2> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  1276. {
  1277. var isSingle = QueryBuilder.IsSingle();
  1278. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1279. var fieldName = lamResult.GetResultString();
  1280. In(fieldName, inValues);
  1281. return this;
  1282. }
  1283. public new ISugarQueryable<T, T2> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  1284. {
  1285. var sqlObj = childQueryExpression.ToSql();
  1286. _InQueryable(expression, sqlObj);
  1287. return this;
  1288. }
  1289. #endregion
  1290. #region Other
  1291. public new ISugarQueryable<T, T2> AS<AsT>(string tableName)
  1292. {
  1293. var entityName = typeof(AsT).Name;
  1294. _As(tableName, entityName);
  1295. return this;
  1296. }
  1297. public new ISugarQueryable<T, T2> AS(string tableName)
  1298. {
  1299. var entityName = typeof(T).Name;
  1300. _As(tableName, entityName);
  1301. return this;
  1302. }
  1303. public new ISugarQueryable<T, T2> Filter(string FilterName, bool isDisabledGobalFilter = false)
  1304. {
  1305. _Filter(FilterName, isDisabledGobalFilter);
  1306. return this;
  1307. }
  1308. public new ISugarQueryable<T, T2> AddParameters(object parameters)
  1309. {
  1310. if (parameters != null)
  1311. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  1312. return this;
  1313. }
  1314. public new ISugarQueryable<T, T2> AddParameters(SugarParameter[] parameters)
  1315. {
  1316. if (parameters != null)
  1317. QueryBuilder.Parameters.AddRange(parameters);
  1318. return this;
  1319. }
  1320. public new ISugarQueryable<T, T2> AddParameters(List<SugarParameter> parameters)
  1321. {
  1322. if (parameters != null)
  1323. QueryBuilder.Parameters.AddRange(parameters);
  1324. return this;
  1325. }
  1326. public new ISugarQueryable<T, T2> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  1327. {
  1328. QueryBuilder.JoinIndex = +1;
  1329. QueryBuilder.JoinQueryInfos
  1330. .Add(new JoinQueryInfo
  1331. {
  1332. JoinIndex = QueryBuilder.JoinIndex,
  1333. TableName = tableName,
  1334. ShortName = shortName,
  1335. JoinType = type,
  1336. JoinWhere = joinWhere
  1337. });
  1338. return this;
  1339. }
  1340. public new ISugarQueryable<T, T2> With(string withString)
  1341. {
  1342. base.With(withString);
  1343. return this;
  1344. }
  1345. public new ISugarQueryable<T, T2> WithCache(int cacheDurationInSeconds = int.MaxValue)
  1346. {
  1347. this.IsCache = true;
  1348. this.CacheTime = cacheDurationInSeconds;
  1349. return this;
  1350. }
  1351. public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  1352. {
  1353. if (isCache)
  1354. {
  1355. this.IsCache = true;
  1356. this.CacheTime = cacheDurationInSeconds;
  1357. }
  1358. return this;
  1359. }
  1360. #endregion
  1361. }
  1362. #endregion
  1363. #region T3
  1364. public partial class QueryableProvider<T, T2, T3> : QueryableProvider<T>, ISugarQueryable<T, T2, T3>
  1365. {
  1366. #region Group
  1367. public ISugarQueryable<T, T2, T3> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  1368. {
  1369. _GroupBy(expression);
  1370. return this;
  1371. }
  1372. public ISugarQueryable<T, T2, T3> GroupBy(Expression<Func<T, T2, object>> expression)
  1373. {
  1374. _GroupBy(expression);
  1375. return this;
  1376. }
  1377. public new ISugarQueryable<T, T2, T3> GroupBy(Expression<Func<T, object>> expression)
  1378. {
  1379. _GroupBy(expression);
  1380. return this;
  1381. }
  1382. public new ISugarQueryable<T, T2, T3> Having(Expression<Func<T, bool>> expression)
  1383. {
  1384. this._Having(expression);
  1385. return this;
  1386. }
  1387. public ISugarQueryable<T, T2, T3> Having(Expression<Func<T, T2, bool>> expression)
  1388. {
  1389. this._Having(expression);
  1390. return this;
  1391. }
  1392. public ISugarQueryable<T, T2, T3> Having(Expression<Func<T, T2, T3, bool>> expression)
  1393. {
  1394. this._Having(expression);
  1395. return this;
  1396. }
  1397. public new ISugarQueryable<T, T2, T3> Having(string whereString, object whereObj)
  1398. {
  1399. base.Having(whereString, whereObj);
  1400. return this;
  1401. }
  1402. #endregion
  1403. #region Order
  1404. public ISugarQueryable<T, T2, T3> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  1405. {
  1406. _OrderBy(expression, type);
  1407. return this;
  1408. }
  1409. public ISugarQueryable<T, T2, T3> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  1410. {
  1411. _OrderBy(expression, type);
  1412. return this;
  1413. }
  1414. public new ISugarQueryable<T, T2, T3> OrderBy(Expression<Func<T, object>> expression, OrderByType type)
  1415. {
  1416. _OrderBy(expression, type);
  1417. return this;
  1418. }
  1419. public new ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, string orderFileds)
  1420. {
  1421. if (isOrderBy)
  1422. base.OrderBy(orderFileds);
  1423. return this;
  1424. }
  1425. public new ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  1426. {
  1427. if (isOrderBy)
  1428. _OrderBy(expression, type);
  1429. return this;
  1430. }
  1431. public ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  1432. {
  1433. if (isOrderBy)
  1434. _OrderBy(expression, type);
  1435. return this;
  1436. }
  1437. public ISugarQueryable<T, T2, T3> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  1438. {
  1439. if (isOrderBy)
  1440. _OrderBy(expression, type);
  1441. return this;
  1442. }
  1443. #endregion
  1444. #region Select
  1445. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1446. {
  1447. return _Select<TResult>(expression);
  1448. }
  1449. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  1450. {
  1451. return _Select<TResult>(expression);
  1452. }
  1453. public ISugarQueryable<T, T2, T3> Where(Expression<Func<T, T2, T3, bool>> expression)
  1454. {
  1455. _Where(expression);
  1456. return this;
  1457. }
  1458. #endregion
  1459. #region Where
  1460. public ISugarQueryable<T, T2, T3> Where(Expression<Func<T, T2, bool>> expression)
  1461. {
  1462. _Where(expression);
  1463. return this;
  1464. }
  1465. public new ISugarQueryable<T, T2, T3> Where(Expression<Func<T, bool>> expression)
  1466. {
  1467. _Where(expression);
  1468. return this;
  1469. }
  1470. public new ISugarQueryable<T, T2, T3> Where(List<IConditionalModel> conditionalModels)
  1471. {
  1472. base.Where(conditionalModels);
  1473. return this;
  1474. }
  1475. public ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  1476. {
  1477. if (isWhere)
  1478. _Where(expression);
  1479. return this;
  1480. }
  1481. public ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  1482. {
  1483. if (isWhere)
  1484. _Where(expression);
  1485. return this;
  1486. }
  1487. public new ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  1488. {
  1489. if (isWhere)
  1490. _Where(expression);
  1491. return this;
  1492. }
  1493. public new ISugarQueryable<T, T2, T3> Where(string whereString, object whereObj)
  1494. {
  1495. Where<T>(whereString, whereObj);
  1496. return this;
  1497. }
  1498. public new ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, string whereString, object whereObj)
  1499. {
  1500. if (!isWhere) return this;
  1501. this.Where<T>(whereString, whereObj);
  1502. return this;
  1503. }
  1504. #endregion
  1505. #region Aggr
  1506. public TResult Max<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1507. {
  1508. return _Max<TResult>(expression);
  1509. }
  1510. public TResult Min<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1511. {
  1512. return _Min<TResult>(expression);
  1513. }
  1514. public TResult Sum<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1515. {
  1516. return _Sum<TResult>(expression);
  1517. }
  1518. public TResult Avg<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1519. {
  1520. return _Avg<TResult>(expression);
  1521. }
  1522. #endregion
  1523. #region In
  1524. public new ISugarQueryable<T, T2, T3> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  1525. {
  1526. var isSingle = QueryBuilder.IsSingle();
  1527. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1528. var fieldName = lamResult.GetResultString();
  1529. In(fieldName, inValues);
  1530. return this;
  1531. }
  1532. public new ISugarQueryable<T, T2, T3> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  1533. {
  1534. var isSingle = QueryBuilder.IsSingle();
  1535. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1536. var fieldName = lamResult.GetResultString();
  1537. In(fieldName, inValues);
  1538. return this;
  1539. }
  1540. public new ISugarQueryable<T, T2, T3> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  1541. {
  1542. var sqlObj = childQueryExpression.ToSql();
  1543. _InQueryable(expression, sqlObj);
  1544. return this;
  1545. }
  1546. #endregion
  1547. #region Other
  1548. public new ISugarQueryable<T, T2, T3> AS<AsT>(string tableName)
  1549. {
  1550. var entityName = typeof(AsT).Name;
  1551. _As(tableName, entityName);
  1552. return this;
  1553. }
  1554. public new ISugarQueryable<T, T2, T3> AS(string tableName)
  1555. {
  1556. var entityName = typeof(T).Name;
  1557. _As(tableName, entityName);
  1558. return this;
  1559. }
  1560. public new ISugarQueryable<T, T2, T3> Filter(string FilterName, bool isDisabledGobalFilter = false)
  1561. {
  1562. _Filter(FilterName, isDisabledGobalFilter);
  1563. return this;
  1564. }
  1565. public new ISugarQueryable<T, T2, T3> AddParameters(object parameters)
  1566. {
  1567. if (parameters != null)
  1568. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  1569. return this;
  1570. }
  1571. public new ISugarQueryable<T, T2, T3> AddParameters(SugarParameter[] parameters)
  1572. {
  1573. if (parameters != null)
  1574. QueryBuilder.Parameters.AddRange(parameters);
  1575. return this;
  1576. }
  1577. public new ISugarQueryable<T, T2, T3> AddParameters(List<SugarParameter> parameters)
  1578. {
  1579. if (parameters != null)
  1580. QueryBuilder.Parameters.AddRange(parameters);
  1581. return this;
  1582. }
  1583. public new ISugarQueryable<T, T2, T3> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  1584. {
  1585. QueryBuilder.JoinIndex = +1;
  1586. QueryBuilder.JoinQueryInfos
  1587. .Add(new JoinQueryInfo
  1588. {
  1589. JoinIndex = QueryBuilder.JoinIndex,
  1590. TableName = tableName,
  1591. ShortName = shortName,
  1592. JoinType = type,
  1593. JoinWhere = joinWhere
  1594. });
  1595. return this;
  1596. }
  1597. public new ISugarQueryable<T, T2, T3> With(string withString)
  1598. {
  1599. base.With(withString);
  1600. return this;
  1601. }
  1602. public new ISugarQueryable<T, T2, T3> WithCache(int cacheDurationInSeconds = int.MaxValue)
  1603. {
  1604. this.IsCache = true;
  1605. this.CacheTime = cacheDurationInSeconds;
  1606. return this;
  1607. }
  1608. public new ISugarQueryable<T, T2, T3> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  1609. {
  1610. if (IsCache)
  1611. {
  1612. this.IsCache = true;
  1613. this.CacheTime = cacheDurationInSeconds;
  1614. }
  1615. return this;
  1616. }
  1617. #endregion
  1618. }
  1619. #endregion
  1620. #region T4
  1621. public partial class QueryableProvider<T, T2, T3, T4> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4>
  1622. {
  1623. #region Where
  1624. public new ISugarQueryable<T, T2, T3, T4> Where(Expression<Func<T, bool>> expression)
  1625. {
  1626. _Where(expression);
  1627. return this;
  1628. }
  1629. public ISugarQueryable<T, T2, T3, T4> Where(Expression<Func<T, T2, bool>> expression)
  1630. {
  1631. _Where(expression);
  1632. return this;
  1633. }
  1634. public ISugarQueryable<T, T2, T3, T4> Where(Expression<Func<T, T2, T3, bool>> expression)
  1635. {
  1636. _Where(expression);
  1637. return this;
  1638. }
  1639. public ISugarQueryable<T, T2, T3, T4> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  1640. {
  1641. _Where(expression);
  1642. return this;
  1643. }
  1644. public new ISugarQueryable<T, T2, T3, T4> Where(List<IConditionalModel> conditionalModels)
  1645. {
  1646. base.Where(conditionalModels);
  1647. return this;
  1648. }
  1649. public new ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  1650. {
  1651. if (isWhere)
  1652. _Where(expression);
  1653. return this;
  1654. }
  1655. public ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  1656. {
  1657. if (isWhere)
  1658. _Where(expression);
  1659. return this;
  1660. }
  1661. public ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  1662. {
  1663. if (isWhere)
  1664. _Where(expression);
  1665. return this;
  1666. }
  1667. public ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  1668. {
  1669. if (isWhere)
  1670. _Where(expression);
  1671. return this;
  1672. }
  1673. public new ISugarQueryable<T, T2, T3, T4> Where(string whereString, object whereObj)
  1674. {
  1675. Where<T>(whereString, whereObj);
  1676. return this;
  1677. }
  1678. public new ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, string whereString, object whereObj)
  1679. {
  1680. if (!isWhere) return this;
  1681. this.Where<T>(whereString, whereObj);
  1682. return this;
  1683. }
  1684. #endregion
  1685. #region Select
  1686. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  1687. {
  1688. return _Select<TResult>(expression);
  1689. }
  1690. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1691. {
  1692. return _Select<TResult>(expression);
  1693. }
  1694. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  1695. {
  1696. return _Select<TResult>(expression);
  1697. }
  1698. #endregion
  1699. #region OrderBy
  1700. public new ISugarQueryable<T, T2, T3, T4> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  1701. {
  1702. _OrderBy(expression, type);
  1703. return this;
  1704. }
  1705. public ISugarQueryable<T, T2, T3, T4> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  1706. {
  1707. _OrderBy(expression, type);
  1708. return this;
  1709. }
  1710. public ISugarQueryable<T, T2, T3, T4> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  1711. {
  1712. _OrderBy(expression, type);
  1713. return this;
  1714. }
  1715. public ISugarQueryable<T, T2, T3, T4> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  1716. {
  1717. _OrderBy(expression, type);
  1718. return this;
  1719. }
  1720. public new ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, string orderFileds)
  1721. {
  1722. if (isOrderBy)
  1723. base.OrderBy(orderFileds);
  1724. return this;
  1725. }
  1726. public new ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  1727. {
  1728. if (isOrderBy)
  1729. _OrderBy(expression, type);
  1730. return this;
  1731. }
  1732. public ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  1733. {
  1734. if (isOrderBy)
  1735. _OrderBy(expression, type);
  1736. return this;
  1737. }
  1738. public ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  1739. {
  1740. if (isOrderBy)
  1741. _OrderBy(expression, type);
  1742. return this;
  1743. }
  1744. public ISugarQueryable<T, T2, T3, T4> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  1745. {
  1746. if (isOrderBy)
  1747. _OrderBy(expression, type);
  1748. return this;
  1749. }
  1750. #endregion
  1751. #region GroupBy
  1752. public new ISugarQueryable<T, T2, T3, T4> GroupBy(Expression<Func<T, object>> expression)
  1753. {
  1754. _GroupBy(expression);
  1755. return this;
  1756. }
  1757. public ISugarQueryable<T, T2, T3, T4> GroupBy(Expression<Func<T, T2, object>> expression)
  1758. {
  1759. _GroupBy(expression);
  1760. return this;
  1761. }
  1762. public ISugarQueryable<T, T2, T3, T4> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  1763. {
  1764. _GroupBy(expression);
  1765. return this;
  1766. }
  1767. public ISugarQueryable<T, T2, T3, T4> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  1768. {
  1769. _GroupBy(expression);
  1770. return this;
  1771. }
  1772. public new ISugarQueryable<T, T2, T3, T4> Having(Expression<Func<T, bool>> expression)
  1773. {
  1774. this._Having(expression);
  1775. return this;
  1776. }
  1777. public ISugarQueryable<T, T2, T3, T4> Having(Expression<Func<T, T2, bool>> expression)
  1778. {
  1779. this._Having(expression);
  1780. return this;
  1781. }
  1782. public ISugarQueryable<T, T2, T3, T4> Having(Expression<Func<T, T2, T3, bool>> expression)
  1783. {
  1784. this._Having(expression);
  1785. return this;
  1786. }
  1787. public ISugarQueryable<T, T2, T3, T4> Having(Expression<Func<T, T2, T3, T4, bool>> expression)
  1788. {
  1789. this._Having(expression);
  1790. return this;
  1791. }
  1792. public new ISugarQueryable<T, T2, T3, T4> Having(string whereString, object whereObj)
  1793. {
  1794. base.Having(whereString, whereObj);
  1795. return this;
  1796. }
  1797. #endregion
  1798. #region Aggr
  1799. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  1800. {
  1801. return _Max<TResult>(expression);
  1802. }
  1803. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  1804. {
  1805. return _Min<TResult>(expression);
  1806. }
  1807. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  1808. {
  1809. return _Sum<TResult>(expression);
  1810. }
  1811. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  1812. {
  1813. return _Avg<TResult>(expression);
  1814. }
  1815. #endregion
  1816. #region In
  1817. public new ISugarQueryable<T, T2, T3, T4> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  1818. {
  1819. var isSingle = QueryBuilder.IsSingle();
  1820. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1821. var fieldName = lamResult.GetResultString();
  1822. In(fieldName, inValues);
  1823. return this;
  1824. }
  1825. public new ISugarQueryable<T, T2, T3, T4> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  1826. {
  1827. var isSingle = QueryBuilder.IsSingle();
  1828. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  1829. var fieldName = lamResult.GetResultString();
  1830. In(fieldName, inValues);
  1831. return this;
  1832. }
  1833. public new ISugarQueryable<T, T2, T3, T4> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  1834. {
  1835. var sqlObj = childQueryExpression.ToSql();
  1836. _InQueryable(expression, sqlObj);
  1837. return this;
  1838. }
  1839. #endregion
  1840. #region Other
  1841. public new ISugarQueryable<T, T2, T3, T4> AS<AsT>(string tableName)
  1842. {
  1843. var entityName = typeof(AsT).Name;
  1844. _As(tableName, entityName);
  1845. return this;
  1846. }
  1847. public new ISugarQueryable<T, T2, T3, T4> AS(string tableName)
  1848. {
  1849. var entityName = typeof(T).Name;
  1850. _As(tableName, entityName);
  1851. return this;
  1852. }
  1853. public new ISugarQueryable<T, T2, T3, T4> Filter(string FilterName, bool isDisabledGobalFilter = false)
  1854. {
  1855. _Filter(FilterName, isDisabledGobalFilter);
  1856. return this;
  1857. }
  1858. public new ISugarQueryable<T, T2, T3, T4> AddParameters(object parameters)
  1859. {
  1860. if (parameters != null)
  1861. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  1862. return this;
  1863. }
  1864. public new ISugarQueryable<T, T2, T3, T4> AddParameters(SugarParameter[] parameters)
  1865. {
  1866. if (parameters != null)
  1867. QueryBuilder.Parameters.AddRange(parameters);
  1868. return this;
  1869. }
  1870. public new ISugarQueryable<T, T2, T3, T4> AddParameters(List<SugarParameter> parameters)
  1871. {
  1872. if (parameters != null)
  1873. QueryBuilder.Parameters.AddRange(parameters);
  1874. return this;
  1875. }
  1876. public new ISugarQueryable<T, T2, T3, T4> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  1877. {
  1878. QueryBuilder.JoinIndex = +1;
  1879. QueryBuilder.JoinQueryInfos
  1880. .Add(new JoinQueryInfo
  1881. {
  1882. JoinIndex = QueryBuilder.JoinIndex,
  1883. TableName = tableName,
  1884. ShortName = shortName,
  1885. JoinType = type,
  1886. JoinWhere = joinWhere
  1887. });
  1888. return this;
  1889. }
  1890. public new ISugarQueryable<T, T2, T3, T4> With(string withString)
  1891. {
  1892. base.With(withString);
  1893. return this;
  1894. }
  1895. public new ISugarQueryable<T, T2, T3, T4> WithCache(int cacheDurationInSeconds = int.MaxValue)
  1896. {
  1897. this.IsCache = true;
  1898. this.CacheTime = cacheDurationInSeconds;
  1899. return this;
  1900. }
  1901. public new ISugarQueryable<T, T2, T3, T4> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  1902. {
  1903. if (IsCache)
  1904. {
  1905. this.IsCache = true;
  1906. this.CacheTime = cacheDurationInSeconds;
  1907. }
  1908. return this;
  1909. }
  1910. #endregion
  1911. }
  1912. #endregion
  1913. #region T5
  1914. public partial class QueryableProvider<T, T2, T3, T4, T5> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5>
  1915. {
  1916. #region Where
  1917. public new ISugarQueryable<T, T2, T3, T4, T5> Where(Expression<Func<T, bool>> expression)
  1918. {
  1919. _Where(expression);
  1920. return this;
  1921. }
  1922. public ISugarQueryable<T, T2, T3, T4, T5> Where(Expression<Func<T, T2, bool>> expression)
  1923. {
  1924. _Where(expression);
  1925. return this;
  1926. }
  1927. public ISugarQueryable<T, T2, T3, T4, T5> Where(Expression<Func<T, T2, T3, bool>> expression)
  1928. {
  1929. _Where(expression);
  1930. return this;
  1931. }
  1932. public ISugarQueryable<T, T2, T3, T4, T5> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  1933. {
  1934. _Where(expression);
  1935. return this;
  1936. }
  1937. public ISugarQueryable<T, T2, T3, T4, T5> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  1938. {
  1939. _Where(expression);
  1940. return this;
  1941. }
  1942. public new ISugarQueryable<T, T2, T3, T4, T5> Where(List<IConditionalModel> conditionalModels)
  1943. {
  1944. base.Where(conditionalModels);
  1945. return this;
  1946. }
  1947. public new ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  1948. {
  1949. if (isWhere)
  1950. _Where(expression);
  1951. return this;
  1952. }
  1953. public ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  1954. {
  1955. if (isWhere)
  1956. _Where(expression);
  1957. return this;
  1958. }
  1959. public ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  1960. {
  1961. if (isWhere)
  1962. _Where(expression);
  1963. return this;
  1964. }
  1965. public ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  1966. {
  1967. if (isWhere)
  1968. _Where(expression);
  1969. return this;
  1970. }
  1971. public ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  1972. {
  1973. if (isWhere)
  1974. _Where(expression);
  1975. return this;
  1976. }
  1977. public new ISugarQueryable<T, T2, T3, T4, T5> Where(string whereString, object whereObj)
  1978. {
  1979. Where<T>(whereString, whereObj);
  1980. return this;
  1981. }
  1982. public new ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, string whereString, object whereObj)
  1983. {
  1984. if (!isWhere) return this;
  1985. this.Where<T>(whereString, whereObj);
  1986. return this;
  1987. }
  1988. #endregion
  1989. #region Select
  1990. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  1991. {
  1992. return _Select<TResult>(expression);
  1993. }
  1994. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  1995. {
  1996. return _Select<TResult>(expression);
  1997. }
  1998. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  1999. {
  2000. return _Select<TResult>(expression);
  2001. }
  2002. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2003. {
  2004. return _Select<TResult>(expression);
  2005. }
  2006. #endregion
  2007. #region OrderBy
  2008. public new ISugarQueryable<T, T2, T3, T4, T5> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  2009. {
  2010. _OrderBy(expression, type);
  2011. return this;
  2012. }
  2013. public ISugarQueryable<T, T2, T3, T4, T5> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  2014. {
  2015. _OrderBy(expression, type);
  2016. return this;
  2017. }
  2018. public ISugarQueryable<T, T2, T3, T4, T5> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  2019. {
  2020. _OrderBy(expression, type);
  2021. return this;
  2022. }
  2023. public ISugarQueryable<T, T2, T3, T4, T5> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  2024. {
  2025. _OrderBy(expression, type);
  2026. return this;
  2027. }
  2028. public ISugarQueryable<T, T2, T3, T4, T5> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  2029. {
  2030. _OrderBy(expression, type);
  2031. return this;
  2032. }
  2033. public new ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, string orderFileds)
  2034. {
  2035. if (isOrderBy)
  2036. base.OrderBy(orderFileds);
  2037. return this;
  2038. }
  2039. public new ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  2040. {
  2041. if (isOrderBy)
  2042. _OrderBy(expression, type);
  2043. return this;
  2044. }
  2045. public ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  2046. {
  2047. if (isOrderBy)
  2048. _OrderBy(expression, type);
  2049. return this;
  2050. }
  2051. public ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  2052. {
  2053. if (isOrderBy)
  2054. _OrderBy(expression, type);
  2055. return this;
  2056. }
  2057. public ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  2058. {
  2059. if (isOrderBy)
  2060. _OrderBy(expression, type);
  2061. return this;
  2062. }
  2063. public ISugarQueryable<T, T2, T3, T4, T5> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  2064. {
  2065. if (isOrderBy)
  2066. _OrderBy(expression, type);
  2067. return this;
  2068. }
  2069. #endregion
  2070. #region GroupBy
  2071. public new ISugarQueryable<T, T2, T3, T4, T5> GroupBy(Expression<Func<T, object>> expression)
  2072. {
  2073. _GroupBy(expression);
  2074. return this;
  2075. }
  2076. public ISugarQueryable<T, T2, T3, T4, T5> GroupBy(Expression<Func<T, T2, object>> expression)
  2077. {
  2078. _GroupBy(expression);
  2079. return this;
  2080. }
  2081. public ISugarQueryable<T, T2, T3, T4, T5> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  2082. {
  2083. _GroupBy(expression);
  2084. return this;
  2085. }
  2086. public ISugarQueryable<T, T2, T3, T4, T5> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  2087. {
  2088. _GroupBy(expression);
  2089. return this;
  2090. }
  2091. public ISugarQueryable<T, T2, T3, T4, T5> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  2092. {
  2093. _GroupBy(expression);
  2094. return this;
  2095. }
  2096. #endregion
  2097. #region Aggr
  2098. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2099. {
  2100. return _Max<TResult>(expression);
  2101. }
  2102. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2103. {
  2104. return _Min<TResult>(expression);
  2105. }
  2106. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2107. {
  2108. return _Sum<TResult>(expression);
  2109. }
  2110. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2111. {
  2112. return _Avg<TResult>(expression);
  2113. }
  2114. #endregion
  2115. #region In
  2116. public new ISugarQueryable<T, T2, T3, T4, T5> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  2117. {
  2118. var isSingle = QueryBuilder.IsSingle();
  2119. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  2120. var fieldName = lamResult.GetResultString();
  2121. In(fieldName, inValues);
  2122. return this;
  2123. }
  2124. public new ISugarQueryable<T, T2, T3, T4, T5> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  2125. {
  2126. var isSingle = QueryBuilder.IsSingle();
  2127. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  2128. var fieldName = lamResult.GetResultString();
  2129. In(fieldName, inValues);
  2130. return this;
  2131. }
  2132. public new ISugarQueryable<T, T2, T3, T4, T5> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  2133. {
  2134. var sqlObj = childQueryExpression.ToSql();
  2135. _InQueryable(expression, sqlObj);
  2136. return this;
  2137. }
  2138. #endregion
  2139. #region Other
  2140. public new ISugarQueryable<T, T2, T3, T4, T5> AS<AsT>(string tableName)
  2141. {
  2142. var entityName = typeof(AsT).Name;
  2143. _As(tableName, entityName);
  2144. return this;
  2145. }
  2146. public new ISugarQueryable<T, T2, T3, T4, T5> AS(string tableName)
  2147. {
  2148. var entityName = typeof(T).Name;
  2149. _As(tableName, entityName);
  2150. return this;
  2151. }
  2152. public new ISugarQueryable<T, T2, T3, T4, T5> Filter(string FilterName, bool isDisabledGobalFilter = false)
  2153. {
  2154. _Filter(FilterName, isDisabledGobalFilter);
  2155. return this;
  2156. }
  2157. public new ISugarQueryable<T, T2, T3, T4, T5> AddParameters(object parameters)
  2158. {
  2159. if (parameters != null)
  2160. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  2161. return this;
  2162. }
  2163. public new ISugarQueryable<T, T2, T3, T4, T5> AddParameters(SugarParameter[] parameters)
  2164. {
  2165. if (parameters != null)
  2166. QueryBuilder.Parameters.AddRange(parameters);
  2167. return this;
  2168. }
  2169. public new ISugarQueryable<T, T2, T3, T4, T5> AddParameters(List<SugarParameter> parameters)
  2170. {
  2171. if (parameters != null)
  2172. QueryBuilder.Parameters.AddRange(parameters);
  2173. return this;
  2174. }
  2175. public new ISugarQueryable<T, T2, T3, T4, T5> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  2176. {
  2177. QueryBuilder.JoinIndex = +1;
  2178. QueryBuilder.JoinQueryInfos
  2179. .Add(new JoinQueryInfo
  2180. {
  2181. JoinIndex = QueryBuilder.JoinIndex,
  2182. TableName = tableName,
  2183. ShortName = shortName,
  2184. JoinType = type,
  2185. JoinWhere = joinWhere
  2186. });
  2187. return this;
  2188. }
  2189. public new ISugarQueryable<T, T2, T3, T4, T5> With(string withString)
  2190. {
  2191. base.With(withString);
  2192. return this;
  2193. }
  2194. public new ISugarQueryable<T, T2, T3, T4, T5> WithCache(int cacheDurationInSeconds = int.MaxValue)
  2195. {
  2196. this.IsCache = true;
  2197. this.CacheTime = cacheDurationInSeconds;
  2198. return this;
  2199. }
  2200. public new ISugarQueryable<T, T2, T3, T4, T5> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  2201. {
  2202. if (IsCache)
  2203. {
  2204. this.IsCache = true;
  2205. this.CacheTime = cacheDurationInSeconds;
  2206. }
  2207. return this;
  2208. }
  2209. #endregion
  2210. }
  2211. #endregion
  2212. #region T6
  2213. public partial class QueryableProvider<T, T2, T3, T4, T5, T6> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6>
  2214. {
  2215. #region Where
  2216. public new ISugarQueryable<T, T2, T3, T4, T5, T6> Where(Expression<Func<T, bool>> expression)
  2217. {
  2218. _Where(expression);
  2219. return this;
  2220. }
  2221. public ISugarQueryable<T, T2, T3, T4, T5, T6> Where(Expression<Func<T, T2, bool>> expression)
  2222. {
  2223. _Where(expression);
  2224. return this;
  2225. }
  2226. public ISugarQueryable<T, T2, T3, T4, T5, T6> Where(Expression<Func<T, T2, T3, bool>> expression)
  2227. {
  2228. _Where(expression);
  2229. return this;
  2230. }
  2231. public ISugarQueryable<T, T2, T3, T4, T5, T6> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  2232. {
  2233. _Where(expression);
  2234. return this;
  2235. }
  2236. public ISugarQueryable<T, T2, T3, T4, T5, T6> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  2237. {
  2238. _Where(expression);
  2239. return this;
  2240. }
  2241. public ISugarQueryable<T, T2, T3, T4, T5, T6> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  2242. {
  2243. _Where(expression);
  2244. return this;
  2245. }
  2246. public new ISugarQueryable<T, T2, T3, T4, T5, T6> Where(List<IConditionalModel> conditionalModels)
  2247. {
  2248. base.Where(conditionalModels);
  2249. return this;
  2250. }
  2251. public new ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  2252. {
  2253. if (isWhere)
  2254. _Where(expression);
  2255. return this;
  2256. }
  2257. public ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  2258. {
  2259. if (isWhere)
  2260. _Where(expression);
  2261. return this;
  2262. }
  2263. public ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  2264. {
  2265. if (isWhere)
  2266. _Where(expression);
  2267. return this;
  2268. }
  2269. public ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  2270. {
  2271. if (isWhere)
  2272. _Where(expression);
  2273. return this;
  2274. }
  2275. public ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  2276. {
  2277. if (isWhere)
  2278. _Where(expression);
  2279. return this;
  2280. }
  2281. public ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  2282. {
  2283. if (isWhere)
  2284. _Where(expression);
  2285. return this;
  2286. }
  2287. public new ISugarQueryable<T, T2, T3, T4, T5, T6> Where(string whereString, object whereObj)
  2288. {
  2289. Where<T>(whereString, whereObj);
  2290. return this;
  2291. }
  2292. public new ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, string whereString, object whereObj)
  2293. {
  2294. if (!isWhere) return this;
  2295. this.Where<T>(whereString, whereObj);
  2296. return this;
  2297. }
  2298. #endregion
  2299. #region Select
  2300. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  2301. {
  2302. return _Select<TResult>(expression);
  2303. }
  2304. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  2305. {
  2306. return _Select<TResult>(expression);
  2307. }
  2308. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  2309. {
  2310. return _Select<TResult>(expression);
  2311. }
  2312. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2313. {
  2314. return _Select<TResult>(expression);
  2315. }
  2316. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2317. {
  2318. return _Select<TResult>(expression);
  2319. }
  2320. #endregion
  2321. #region OrderBy
  2322. public new ISugarQueryable<T, T2, T3, T4, T5, T6> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  2323. {
  2324. _OrderBy(expression, type);
  2325. return this;
  2326. }
  2327. public ISugarQueryable<T, T2, T3, T4, T5, T6> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  2328. {
  2329. _OrderBy(expression, type);
  2330. return this;
  2331. }
  2332. public ISugarQueryable<T, T2, T3, T4, T5, T6> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  2333. {
  2334. _OrderBy(expression, type);
  2335. return this;
  2336. }
  2337. public ISugarQueryable<T, T2, T3, T4, T5, T6> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  2338. {
  2339. _OrderBy(expression, type);
  2340. return this;
  2341. }
  2342. public ISugarQueryable<T, T2, T3, T4, T5, T6> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  2343. {
  2344. _OrderBy(expression, type);
  2345. return this;
  2346. }
  2347. public ISugarQueryable<T, T2, T3, T4, T5, T6> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  2348. {
  2349. _OrderBy(expression, type);
  2350. return this;
  2351. }
  2352. #endregion
  2353. #region GroupBy
  2354. public new ISugarQueryable<T, T2, T3, T4, T5, T6> GroupBy(Expression<Func<T, object>> expression)
  2355. {
  2356. _GroupBy(expression);
  2357. return this;
  2358. }
  2359. public ISugarQueryable<T, T2, T3, T4, T5, T6> GroupBy(Expression<Func<T, T2, object>> expression)
  2360. {
  2361. _GroupBy(expression);
  2362. return this;
  2363. }
  2364. public ISugarQueryable<T, T2, T3, T4, T5, T6> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  2365. {
  2366. _GroupBy(expression);
  2367. return this;
  2368. }
  2369. public ISugarQueryable<T, T2, T3, T4, T5, T6> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  2370. {
  2371. _GroupBy(expression);
  2372. return this;
  2373. }
  2374. public ISugarQueryable<T, T2, T3, T4, T5, T6> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  2375. {
  2376. _GroupBy(expression);
  2377. return this;
  2378. }
  2379. public ISugarQueryable<T, T2, T3, T4, T5, T6> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  2380. {
  2381. _GroupBy(expression);
  2382. return this;
  2383. }
  2384. #endregion
  2385. #region Aggr
  2386. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2387. {
  2388. return _Max<TResult>(expression);
  2389. }
  2390. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2391. {
  2392. return _Min<TResult>(expression);
  2393. }
  2394. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2395. {
  2396. return _Sum<TResult>(expression);
  2397. }
  2398. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2399. {
  2400. return _Avg<TResult>(expression);
  2401. }
  2402. #endregion
  2403. #region In
  2404. public new ISugarQueryable<T, T2, T3, T4, T5, T6> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  2405. {
  2406. var isSingle = QueryBuilder.IsSingle();
  2407. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  2408. var fieldName = lamResult.GetResultString();
  2409. In(fieldName, inValues);
  2410. return this;
  2411. }
  2412. public new ISugarQueryable<T, T2, T3, T4, T5, T6> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  2413. {
  2414. var isSingle = QueryBuilder.IsSingle();
  2415. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  2416. var fieldName = lamResult.GetResultString();
  2417. In(fieldName, inValues);
  2418. return this;
  2419. }
  2420. public new ISugarQueryable<T, T2, T3, T4, T5, T6> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  2421. {
  2422. var sqlObj = childQueryExpression.ToSql();
  2423. _InQueryable(expression, sqlObj);
  2424. return this;
  2425. }
  2426. #endregion
  2427. #region Other
  2428. public new ISugarQueryable<T, T2, T3, T4, T5, T6> AS<AsT>(string tableName)
  2429. {
  2430. var entityName = typeof(AsT).Name;
  2431. _As(tableName, entityName);
  2432. return this;
  2433. }
  2434. public new ISugarQueryable<T, T2, T3, T4, T5, T6> AS(string tableName)
  2435. {
  2436. var entityName = typeof(T).Name;
  2437. _As(tableName, entityName);
  2438. return this;
  2439. }
  2440. public new ISugarQueryable<T, T2, T3, T4, T5, T6> Filter(string FilterName, bool isDisabledGobalFilter = false)
  2441. {
  2442. _Filter(FilterName, isDisabledGobalFilter);
  2443. return this;
  2444. }
  2445. public new ISugarQueryable<T, T2, T3, T4, T5, T6> AddParameters(object parameters)
  2446. {
  2447. if (parameters != null)
  2448. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  2449. return this;
  2450. }
  2451. public new ISugarQueryable<T, T2, T3, T4, T5, T6> AddParameters(SugarParameter[] parameters)
  2452. {
  2453. if (parameters != null)
  2454. QueryBuilder.Parameters.AddRange(parameters);
  2455. return this;
  2456. }
  2457. public new ISugarQueryable<T, T2, T3, T4, T5, T6> AddParameters(List<SugarParameter> parameters)
  2458. {
  2459. if (parameters != null)
  2460. QueryBuilder.Parameters.AddRange(parameters);
  2461. return this;
  2462. }
  2463. public new ISugarQueryable<T, T2, T3, T4, T5, T6> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  2464. {
  2465. QueryBuilder.JoinIndex = +1;
  2466. QueryBuilder.JoinQueryInfos
  2467. .Add(new JoinQueryInfo
  2468. {
  2469. JoinIndex = QueryBuilder.JoinIndex,
  2470. TableName = tableName,
  2471. ShortName = shortName,
  2472. JoinType = type,
  2473. JoinWhere = joinWhere
  2474. });
  2475. return this;
  2476. }
  2477. public new ISugarQueryable<T, T2, T3, T4, T5, T6> With(string withString)
  2478. {
  2479. base.With(withString);
  2480. return this;
  2481. }
  2482. public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCache(int cacheDurationInSeconds = int.MaxValue)
  2483. {
  2484. this.IsCache = true;
  2485. this.CacheTime = cacheDurationInSeconds;
  2486. return this;
  2487. }
  2488. public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  2489. {
  2490. if (IsCache)
  2491. {
  2492. this.IsCache = true;
  2493. this.CacheTime = cacheDurationInSeconds;
  2494. }
  2495. return this;
  2496. }
  2497. #endregion
  2498. }
  2499. #endregion
  2500. #region T7
  2501. public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7>
  2502. {
  2503. #region Where
  2504. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, bool>> expression)
  2505. {
  2506. _Where(expression);
  2507. return this;
  2508. }
  2509. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, bool>> expression)
  2510. {
  2511. _Where(expression);
  2512. return this;
  2513. }
  2514. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, bool>> expression)
  2515. {
  2516. _Where(expression);
  2517. return this;
  2518. }
  2519. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  2520. {
  2521. _Where(expression);
  2522. return this;
  2523. }
  2524. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  2525. {
  2526. _Where(expression);
  2527. return this;
  2528. }
  2529. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  2530. {
  2531. _Where(expression);
  2532. return this;
  2533. }
  2534. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  2535. {
  2536. _Where(expression);
  2537. return this;
  2538. }
  2539. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(List<IConditionalModel> conditionalModels)
  2540. {
  2541. base.Where(conditionalModels);
  2542. return this;
  2543. }
  2544. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  2545. {
  2546. if (isWhere)
  2547. _Where(expression);
  2548. return this;
  2549. }
  2550. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  2551. {
  2552. if (isWhere)
  2553. _Where(expression);
  2554. return this;
  2555. }
  2556. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  2557. {
  2558. if (isWhere)
  2559. _Where(expression);
  2560. return this;
  2561. }
  2562. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  2563. {
  2564. if (isWhere)
  2565. _Where(expression);
  2566. return this;
  2567. }
  2568. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  2569. {
  2570. if (isWhere)
  2571. _Where(expression);
  2572. return this;
  2573. }
  2574. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  2575. {
  2576. if (isWhere)
  2577. _Where(expression);
  2578. return this;
  2579. }
  2580. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  2581. {
  2582. if (isWhere)
  2583. _Where(expression);
  2584. return this;
  2585. }
  2586. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(string whereString, object whereObj)
  2587. {
  2588. Where<T>(whereString, whereObj);
  2589. return this;
  2590. }
  2591. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, string whereString, object whereObj)
  2592. {
  2593. if (!isWhere) return this;
  2594. this.Where<T>(whereString, whereObj);
  2595. return this;
  2596. }
  2597. #endregion
  2598. #region Select
  2599. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  2600. {
  2601. return _Select<TResult>(expression);
  2602. }
  2603. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  2604. {
  2605. return _Select<TResult>(expression);
  2606. }
  2607. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  2608. {
  2609. return _Select<TResult>(expression);
  2610. }
  2611. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2612. {
  2613. return _Select<TResult>(expression);
  2614. }
  2615. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2616. {
  2617. return _Select<TResult>(expression);
  2618. }
  2619. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  2620. {
  2621. return _Select<TResult>(expression);
  2622. }
  2623. #endregion
  2624. #region OrderBy
  2625. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  2626. {
  2627. _OrderBy(expression, type);
  2628. return this;
  2629. }
  2630. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  2631. {
  2632. _OrderBy(expression, type);
  2633. return this;
  2634. }
  2635. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  2636. {
  2637. _OrderBy(expression, type);
  2638. return this;
  2639. }
  2640. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  2641. {
  2642. _OrderBy(expression, type);
  2643. return this;
  2644. }
  2645. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  2646. {
  2647. _OrderBy(expression, type);
  2648. return this;
  2649. }
  2650. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  2651. {
  2652. _OrderBy(expression, type);
  2653. return this;
  2654. }
  2655. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
  2656. {
  2657. _OrderBy(expression, type);
  2658. return this;
  2659. }
  2660. #endregion
  2661. #region GroupBy
  2662. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, object>> expression)
  2663. {
  2664. _GroupBy(expression);
  2665. return this;
  2666. }
  2667. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, T2, object>> expression)
  2668. {
  2669. _GroupBy(expression);
  2670. return this;
  2671. }
  2672. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  2673. {
  2674. _GroupBy(expression);
  2675. return this;
  2676. }
  2677. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  2678. {
  2679. _GroupBy(expression);
  2680. return this;
  2681. }
  2682. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  2683. {
  2684. _GroupBy(expression);
  2685. return this;
  2686. }
  2687. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  2688. {
  2689. _GroupBy(expression);
  2690. return this;
  2691. }
  2692. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression)
  2693. {
  2694. _GroupBy(expression);
  2695. return this;
  2696. }
  2697. #endregion
  2698. #region Aggr
  2699. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  2700. {
  2701. return _Max<TResult>(expression);
  2702. }
  2703. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  2704. {
  2705. return _Min<TResult>(expression);
  2706. }
  2707. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  2708. {
  2709. return _Sum<TResult>(expression);
  2710. }
  2711. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  2712. {
  2713. return _Avg<TResult>(expression);
  2714. }
  2715. #endregion
  2716. #region In
  2717. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  2718. {
  2719. var isSingle = QueryBuilder.IsSingle();
  2720. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  2721. var fieldName = lamResult.GetResultString();
  2722. In(fieldName, inValues);
  2723. return this;
  2724. }
  2725. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  2726. {
  2727. var isSingle = QueryBuilder.IsSingle();
  2728. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  2729. var fieldName = lamResult.GetResultString();
  2730. In(fieldName, inValues);
  2731. return this;
  2732. }
  2733. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  2734. {
  2735. var sqlObj = childQueryExpression.ToSql();
  2736. _InQueryable(expression, sqlObj);
  2737. return this;
  2738. }
  2739. #endregion
  2740. #region Other
  2741. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AS<AsT>(string tableName)
  2742. {
  2743. var entityName = typeof(AsT).Name;
  2744. _As(tableName, entityName);
  2745. return this;
  2746. }
  2747. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AS(string tableName)
  2748. {
  2749. var entityName = typeof(T).Name;
  2750. _As(tableName, entityName);
  2751. return this;
  2752. }
  2753. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Filter(string FilterName, bool isDisabledGobalFilter = false)
  2754. {
  2755. _Filter(FilterName, isDisabledGobalFilter);
  2756. return this;
  2757. }
  2758. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AddParameters(object parameters)
  2759. {
  2760. if (parameters != null)
  2761. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  2762. return this;
  2763. }
  2764. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AddParameters(SugarParameter[] parameters)
  2765. {
  2766. if (parameters != null)
  2767. QueryBuilder.Parameters.AddRange(parameters);
  2768. return this;
  2769. }
  2770. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AddParameters(List<SugarParameter> parameters)
  2771. {
  2772. if (parameters != null)
  2773. QueryBuilder.Parameters.AddRange(parameters);
  2774. return this;
  2775. }
  2776. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  2777. {
  2778. QueryBuilder.JoinIndex = +1;
  2779. QueryBuilder.JoinQueryInfos
  2780. .Add(new JoinQueryInfo
  2781. {
  2782. JoinIndex = QueryBuilder.JoinIndex,
  2783. TableName = tableName,
  2784. ShortName = shortName,
  2785. JoinType = type,
  2786. JoinWhere = joinWhere
  2787. });
  2788. return this;
  2789. }
  2790. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> With(string withString)
  2791. {
  2792. base.With(withString);
  2793. return this;
  2794. }
  2795. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCache(int cacheDurationInSeconds = int.MaxValue)
  2796. {
  2797. this.IsCache = true;
  2798. this.CacheTime = cacheDurationInSeconds;
  2799. return this;
  2800. }
  2801. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  2802. {
  2803. if (IsCache)
  2804. {
  2805. this.IsCache = true;
  2806. this.CacheTime = cacheDurationInSeconds;
  2807. }
  2808. return this;
  2809. }
  2810. #endregion
  2811. }
  2812. #endregion
  2813. #region T8
  2814. public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8>
  2815. {
  2816. #region Where
  2817. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, bool>> expression)
  2818. {
  2819. _Where(expression);
  2820. return this;
  2821. }
  2822. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, bool>> expression)
  2823. {
  2824. _Where(expression);
  2825. return this;
  2826. }
  2827. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, T3, bool>> expression)
  2828. {
  2829. _Where(expression);
  2830. return this;
  2831. }
  2832. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  2833. {
  2834. _Where(expression);
  2835. return this;
  2836. }
  2837. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  2838. {
  2839. _Where(expression);
  2840. return this;
  2841. }
  2842. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  2843. {
  2844. _Where(expression);
  2845. return this;
  2846. }
  2847. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  2848. {
  2849. _Where(expression);
  2850. return this;
  2851. }
  2852. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  2853. {
  2854. _Where(expression);
  2855. return this;
  2856. }
  2857. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(List<IConditionalModel> conditionalModels)
  2858. {
  2859. base.Where(conditionalModels);
  2860. return this;
  2861. }
  2862. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  2863. {
  2864. if (isWhere)
  2865. _Where(expression);
  2866. return this;
  2867. }
  2868. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  2869. {
  2870. if (isWhere)
  2871. _Where(expression);
  2872. return this;
  2873. }
  2874. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  2875. {
  2876. if (isWhere)
  2877. _Where(expression);
  2878. return this;
  2879. }
  2880. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  2881. {
  2882. if (isWhere)
  2883. _Where(expression);
  2884. return this;
  2885. }
  2886. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  2887. {
  2888. if (isWhere)
  2889. _Where(expression);
  2890. return this;
  2891. }
  2892. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  2893. {
  2894. if (isWhere)
  2895. _Where(expression);
  2896. return this;
  2897. }
  2898. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  2899. {
  2900. if (isWhere)
  2901. _Where(expression);
  2902. return this;
  2903. }
  2904. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  2905. {
  2906. if (isWhere)
  2907. _Where(expression);
  2908. return this;
  2909. }
  2910. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Where(string whereString, object whereObj)
  2911. {
  2912. Where<T>(whereString, whereObj);
  2913. return this;
  2914. }
  2915. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, string whereString, object whereObj)
  2916. {
  2917. if (!isWhere) return this;
  2918. this.Where<T>(whereString, whereObj);
  2919. return this;
  2920. }
  2921. #endregion
  2922. #region Select
  2923. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  2924. {
  2925. return _Select<TResult>(expression);
  2926. }
  2927. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  2928. {
  2929. return _Select<TResult>(expression);
  2930. }
  2931. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  2932. {
  2933. return _Select<TResult>(expression);
  2934. }
  2935. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  2936. {
  2937. return _Select<TResult>(expression);
  2938. }
  2939. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  2940. {
  2941. return _Select<TResult>(expression);
  2942. }
  2943. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  2944. {
  2945. return _Select<TResult>(expression);
  2946. }
  2947. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  2948. {
  2949. return _Select<TResult>(expression);
  2950. }
  2951. #endregion
  2952. #region OrderBy
  2953. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  2954. {
  2955. _OrderBy(expression, type);
  2956. return this;
  2957. }
  2958. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  2959. {
  2960. _OrderBy(expression, type);
  2961. return this;
  2962. }
  2963. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  2964. {
  2965. _OrderBy(expression, type);
  2966. return this;
  2967. }
  2968. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  2969. {
  2970. _OrderBy(expression, type);
  2971. return this;
  2972. }
  2973. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  2974. {
  2975. _OrderBy(expression, type);
  2976. return this;
  2977. }
  2978. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  2979. {
  2980. _OrderBy(expression, type);
  2981. return this;
  2982. }
  2983. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
  2984. {
  2985. _OrderBy(expression, type);
  2986. return this;
  2987. }
  2988. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
  2989. {
  2990. _OrderBy(expression, type);
  2991. return this;
  2992. }
  2993. #endregion
  2994. #region GroupBy
  2995. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, object>> expression)
  2996. {
  2997. _GroupBy(expression);
  2998. return this;
  2999. }
  3000. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, object>> expression)
  3001. {
  3002. _GroupBy(expression);
  3003. return this;
  3004. }
  3005. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  3006. {
  3007. _GroupBy(expression);
  3008. return this;
  3009. }
  3010. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  3011. {
  3012. _GroupBy(expression);
  3013. return this;
  3014. }
  3015. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  3016. {
  3017. _GroupBy(expression);
  3018. return this;
  3019. }
  3020. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  3021. {
  3022. _GroupBy(expression);
  3023. return this;
  3024. }
  3025. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression)
  3026. {
  3027. _GroupBy(expression);
  3028. return this;
  3029. }
  3030. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression)
  3031. {
  3032. _GroupBy(expression);
  3033. return this;
  3034. }
  3035. #endregion
  3036. #region Aggr
  3037. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  3038. {
  3039. return _Max<TResult>(expression);
  3040. }
  3041. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  3042. {
  3043. return _Min<TResult>(expression);
  3044. }
  3045. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  3046. {
  3047. return _Sum<TResult>(expression);
  3048. }
  3049. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  3050. {
  3051. return _Avg<TResult>(expression);
  3052. }
  3053. #endregion
  3054. #region In
  3055. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  3056. {
  3057. var isSingle = QueryBuilder.IsSingle();
  3058. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  3059. var fieldName = lamResult.GetResultString();
  3060. In(fieldName, inValues);
  3061. return this;
  3062. }
  3063. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  3064. {
  3065. var isSingle = QueryBuilder.IsSingle();
  3066. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  3067. var fieldName = lamResult.GetResultString();
  3068. In(fieldName, inValues);
  3069. return this;
  3070. }
  3071. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  3072. {
  3073. var sqlObj = childQueryExpression.ToSql();
  3074. _InQueryable(expression, sqlObj);
  3075. return this;
  3076. }
  3077. #endregion
  3078. #region Other
  3079. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AS<AsT>(string tableName)
  3080. {
  3081. var entityName = typeof(AsT).Name;
  3082. _As(tableName, entityName);
  3083. return this;
  3084. }
  3085. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AS(string tableName)
  3086. {
  3087. var entityName = typeof(T).Name;
  3088. _As(tableName, entityName);
  3089. return this;
  3090. }
  3091. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Filter(string FilterName, bool isDisabledGobalFilter = false)
  3092. {
  3093. _Filter(FilterName, isDisabledGobalFilter);
  3094. return this;
  3095. }
  3096. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AddParameters(object parameters)
  3097. {
  3098. if (parameters != null)
  3099. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  3100. return this;
  3101. }
  3102. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AddParameters(SugarParameter[] parameters)
  3103. {
  3104. if (parameters != null)
  3105. QueryBuilder.Parameters.AddRange(parameters);
  3106. return this;
  3107. }
  3108. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AddParameters(List<SugarParameter> parameters)
  3109. {
  3110. if (parameters != null)
  3111. QueryBuilder.Parameters.AddRange(parameters);
  3112. return this;
  3113. }
  3114. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  3115. {
  3116. QueryBuilder.JoinIndex = +1;
  3117. QueryBuilder.JoinQueryInfos
  3118. .Add(new JoinQueryInfo
  3119. {
  3120. JoinIndex = QueryBuilder.JoinIndex,
  3121. TableName = tableName,
  3122. ShortName = shortName,
  3123. JoinType = type,
  3124. JoinWhere = joinWhere
  3125. });
  3126. return this;
  3127. }
  3128. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> With(string withString)
  3129. {
  3130. base.With(withString);
  3131. return this;
  3132. }
  3133. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCache(int cacheDurationInSeconds = int.MaxValue)
  3134. {
  3135. this.IsCache = true;
  3136. this.CacheTime = cacheDurationInSeconds;
  3137. return this;
  3138. }
  3139. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  3140. {
  3141. if (IsCache)
  3142. {
  3143. this.IsCache = true;
  3144. this.CacheTime = cacheDurationInSeconds;
  3145. }
  3146. return this;
  3147. }
  3148. #endregion
  3149. }
  3150. #endregion
  3151. #region T9
  3152. public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>
  3153. {
  3154. #region Where
  3155. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, bool>> expression)
  3156. {
  3157. _Where(expression);
  3158. return this;
  3159. }
  3160. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, bool>> expression)
  3161. {
  3162. _Where(expression);
  3163. return this;
  3164. }
  3165. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, bool>> expression)
  3166. {
  3167. _Where(expression);
  3168. return this;
  3169. }
  3170. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  3171. {
  3172. _Where(expression);
  3173. return this;
  3174. }
  3175. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  3176. {
  3177. _Where(expression);
  3178. return this;
  3179. }
  3180. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  3181. {
  3182. _Where(expression);
  3183. return this;
  3184. }
  3185. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  3186. {
  3187. _Where(expression);
  3188. return this;
  3189. }
  3190. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  3191. {
  3192. _Where(expression);
  3193. return this;
  3194. }
  3195. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  3196. {
  3197. _Where(expression);
  3198. return this;
  3199. }
  3200. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  3201. {
  3202. if (isWhere)
  3203. _Where(expression);
  3204. return this;
  3205. }
  3206. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(List<IConditionalModel> conditionalModels)
  3207. {
  3208. base.Where(conditionalModels);
  3209. return this;
  3210. }
  3211. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  3212. {
  3213. if (isWhere)
  3214. _Where(expression);
  3215. return this;
  3216. }
  3217. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  3218. {
  3219. if (isWhere)
  3220. _Where(expression);
  3221. return this;
  3222. }
  3223. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  3224. {
  3225. if (isWhere)
  3226. _Where(expression);
  3227. return this;
  3228. }
  3229. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  3230. {
  3231. if (isWhere)
  3232. _Where(expression);
  3233. return this;
  3234. }
  3235. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  3236. {
  3237. if (isWhere)
  3238. _Where(expression);
  3239. return this;
  3240. }
  3241. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  3242. {
  3243. if (isWhere)
  3244. _Where(expression);
  3245. return this;
  3246. }
  3247. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  3248. {
  3249. if (isWhere)
  3250. _Where(expression);
  3251. return this;
  3252. }
  3253. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  3254. {
  3255. if (isWhere)
  3256. _Where(expression);
  3257. return this;
  3258. }
  3259. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Where(string whereString, object whereObj)
  3260. {
  3261. Where<T>(whereString, whereObj);
  3262. return this;
  3263. }
  3264. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WhereIF(bool isWhere, string whereString, object whereObj)
  3265. {
  3266. if (!isWhere) return this;
  3267. this.Where<T>(whereString, whereObj);
  3268. return this;
  3269. }
  3270. #endregion
  3271. #region Select
  3272. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  3273. {
  3274. return _Select<TResult>(expression);
  3275. }
  3276. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  3277. {
  3278. return _Select<TResult>(expression);
  3279. }
  3280. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  3281. {
  3282. return _Select<TResult>(expression);
  3283. }
  3284. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  3285. {
  3286. return _Select<TResult>(expression);
  3287. }
  3288. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  3289. {
  3290. return _Select<TResult>(expression);
  3291. }
  3292. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  3293. {
  3294. return _Select<TResult>(expression);
  3295. }
  3296. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  3297. {
  3298. return _Select<TResult>(expression);
  3299. }
  3300. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  3301. {
  3302. return _Select<TResult>(expression);
  3303. }
  3304. #endregion
  3305. #region OrderBy
  3306. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  3307. {
  3308. _OrderBy(expression, type);
  3309. return this;
  3310. }
  3311. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  3312. {
  3313. _OrderBy(expression, type);
  3314. return this;
  3315. }
  3316. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  3317. {
  3318. _OrderBy(expression, type);
  3319. return this;
  3320. }
  3321. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  3322. {
  3323. _OrderBy(expression, type);
  3324. return this;
  3325. }
  3326. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  3327. {
  3328. _OrderBy(expression, type);
  3329. return this;
  3330. }
  3331. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  3332. {
  3333. _OrderBy(expression, type);
  3334. return this;
  3335. }
  3336. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
  3337. {
  3338. _OrderBy(expression, type);
  3339. return this;
  3340. }
  3341. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
  3342. {
  3343. _OrderBy(expression, type);
  3344. return this;
  3345. }
  3346. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
  3347. {
  3348. _OrderBy(expression, type);
  3349. return this;
  3350. }
  3351. #endregion
  3352. #region GroupBy
  3353. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, object>> expression)
  3354. {
  3355. _GroupBy(expression);
  3356. return this;
  3357. }
  3358. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, object>> expression)
  3359. {
  3360. _GroupBy(expression);
  3361. return this;
  3362. }
  3363. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  3364. {
  3365. _GroupBy(expression);
  3366. return this;
  3367. }
  3368. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  3369. {
  3370. _GroupBy(expression);
  3371. return this;
  3372. }
  3373. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  3374. {
  3375. _GroupBy(expression);
  3376. return this;
  3377. }
  3378. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  3379. {
  3380. _GroupBy(expression);
  3381. return this;
  3382. }
  3383. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression)
  3384. {
  3385. _GroupBy(expression);
  3386. return this;
  3387. }
  3388. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression)
  3389. {
  3390. _GroupBy(expression);
  3391. return this;
  3392. }
  3393. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression)
  3394. {
  3395. _GroupBy(expression);
  3396. return this;
  3397. }
  3398. #endregion
  3399. #region Aggr
  3400. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  3401. {
  3402. return _Max<TResult>(expression);
  3403. }
  3404. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  3405. {
  3406. return _Min<TResult>(expression);
  3407. }
  3408. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  3409. {
  3410. return _Sum<TResult>(expression);
  3411. }
  3412. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  3413. {
  3414. return _Avg<TResult>(expression);
  3415. }
  3416. #endregion
  3417. #region In
  3418. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  3419. {
  3420. var isSingle = QueryBuilder.IsSingle();
  3421. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  3422. var fieldName = lamResult.GetResultString();
  3423. In(fieldName, inValues);
  3424. return this;
  3425. }
  3426. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  3427. {
  3428. var isSingle = QueryBuilder.IsSingle();
  3429. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  3430. var fieldName = lamResult.GetResultString();
  3431. In(fieldName, inValues);
  3432. return this;
  3433. }
  3434. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  3435. {
  3436. var sqlObj = childQueryExpression.ToSql();
  3437. _InQueryable(expression, sqlObj);
  3438. return this;
  3439. }
  3440. #endregion
  3441. #region Other
  3442. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AS<AsT>(string tableName)
  3443. {
  3444. var entityName = typeof(AsT).Name;
  3445. _As(tableName, entityName);
  3446. return this;
  3447. }
  3448. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AS(string tableName)
  3449. {
  3450. var entityName = typeof(T).Name;
  3451. _As(tableName, entityName);
  3452. return this;
  3453. }
  3454. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Filter(string FilterName, bool isDisabledGobalFilter = false)
  3455. {
  3456. _Filter(FilterName, isDisabledGobalFilter);
  3457. return this;
  3458. }
  3459. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AddParameters(object parameters)
  3460. {
  3461. if (parameters != null)
  3462. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  3463. return this;
  3464. }
  3465. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AddParameters(SugarParameter[] parameters)
  3466. {
  3467. if (parameters != null)
  3468. QueryBuilder.Parameters.AddRange(parameters);
  3469. return this;
  3470. }
  3471. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AddParameters(List<SugarParameter> parameters)
  3472. {
  3473. if (parameters != null)
  3474. QueryBuilder.Parameters.AddRange(parameters);
  3475. return this;
  3476. }
  3477. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  3478. {
  3479. QueryBuilder.JoinIndex = +1;
  3480. QueryBuilder.JoinQueryInfos
  3481. .Add(new JoinQueryInfo
  3482. {
  3483. JoinIndex = QueryBuilder.JoinIndex,
  3484. TableName = tableName,
  3485. ShortName = shortName,
  3486. JoinType = type,
  3487. JoinWhere = joinWhere
  3488. });
  3489. return this;
  3490. }
  3491. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> With(string withString)
  3492. {
  3493. base.With(withString);
  3494. return this;
  3495. }
  3496. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCache(int cacheDurationInSeconds = int.MaxValue)
  3497. {
  3498. this.IsCache = true;
  3499. this.CacheTime = cacheDurationInSeconds;
  3500. return this;
  3501. }
  3502. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  3503. {
  3504. if (IsCache)
  3505. {
  3506. this.IsCache = true;
  3507. this.CacheTime = cacheDurationInSeconds;
  3508. }
  3509. return this;
  3510. }
  3511. #endregion
  3512. }
  3513. #endregion
  3514. #region T10
  3515. public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>
  3516. {
  3517. #region Where
  3518. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, bool>> expression)
  3519. {
  3520. _Where(expression);
  3521. return this;
  3522. }
  3523. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, bool>> expression)
  3524. {
  3525. _Where(expression);
  3526. return this;
  3527. }
  3528. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, bool>> expression)
  3529. {
  3530. _Where(expression);
  3531. return this;
  3532. }
  3533. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  3534. {
  3535. _Where(expression);
  3536. return this;
  3537. }
  3538. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  3539. {
  3540. _Where(expression);
  3541. return this;
  3542. }
  3543. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  3544. {
  3545. _Where(expression);
  3546. return this;
  3547. }
  3548. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  3549. {
  3550. _Where(expression);
  3551. return this;
  3552. }
  3553. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  3554. {
  3555. _Where(expression);
  3556. return this;
  3557. }
  3558. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  3559. {
  3560. _Where(expression);
  3561. return this;
  3562. }
  3563. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
  3564. {
  3565. _Where(expression);
  3566. return this;
  3567. }
  3568. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(List<IConditionalModel> conditionalModels)
  3569. {
  3570. base.Where(conditionalModels);
  3571. return this;
  3572. }
  3573. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  3574. {
  3575. if (isWhere)
  3576. _Where(expression);
  3577. return this;
  3578. }
  3579. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  3580. {
  3581. if (isWhere)
  3582. _Where(expression);
  3583. return this;
  3584. }
  3585. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  3586. {
  3587. if (isWhere)
  3588. _Where(expression);
  3589. return this;
  3590. }
  3591. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  3592. {
  3593. if (isWhere)
  3594. _Where(expression);
  3595. return this;
  3596. }
  3597. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  3598. {
  3599. if (isWhere)
  3600. _Where(expression);
  3601. return this;
  3602. }
  3603. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  3604. {
  3605. if (isWhere)
  3606. _Where(expression);
  3607. return this;
  3608. }
  3609. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  3610. {
  3611. if (isWhere)
  3612. _Where(expression);
  3613. return this;
  3614. }
  3615. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  3616. {
  3617. if (isWhere)
  3618. _Where(expression);
  3619. return this;
  3620. }
  3621. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  3622. {
  3623. if (isWhere)
  3624. _Where(expression);
  3625. return this;
  3626. }
  3627. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
  3628. {
  3629. if (isWhere)
  3630. _Where(expression);
  3631. return this;
  3632. }
  3633. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Where(string whereString, object whereObj)
  3634. {
  3635. Where<T>(whereString, whereObj);
  3636. return this;
  3637. }
  3638. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WhereIF(bool isWhere, string whereString, object whereObj)
  3639. {
  3640. if (!isWhere) return this;
  3641. this.Where<T>(whereString, whereObj);
  3642. return this;
  3643. }
  3644. #endregion
  3645. #region Select
  3646. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  3647. {
  3648. return _Select<TResult>(expression);
  3649. }
  3650. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  3651. {
  3652. return _Select<TResult>(expression);
  3653. }
  3654. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  3655. {
  3656. return _Select<TResult>(expression);
  3657. }
  3658. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  3659. {
  3660. return _Select<TResult>(expression);
  3661. }
  3662. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  3663. {
  3664. return _Select<TResult>(expression);
  3665. }
  3666. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  3667. {
  3668. return _Select<TResult>(expression);
  3669. }
  3670. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  3671. {
  3672. return _Select<TResult>(expression);
  3673. }
  3674. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  3675. {
  3676. return _Select<TResult>(expression);
  3677. }
  3678. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  3679. {
  3680. return _Select<TResult>(expression);
  3681. }
  3682. #endregion
  3683. #region OrderBy
  3684. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  3685. {
  3686. _OrderBy(expression, type);
  3687. return this;
  3688. }
  3689. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  3690. {
  3691. _OrderBy(expression, type);
  3692. return this;
  3693. }
  3694. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  3695. {
  3696. _OrderBy(expression, type);
  3697. return this;
  3698. }
  3699. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  3700. {
  3701. _OrderBy(expression, type);
  3702. return this;
  3703. }
  3704. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  3705. {
  3706. _OrderBy(expression, type);
  3707. return this;
  3708. }
  3709. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  3710. {
  3711. _OrderBy(expression, type);
  3712. return this;
  3713. }
  3714. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
  3715. {
  3716. _OrderBy(expression, type);
  3717. return this;
  3718. }
  3719. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
  3720. {
  3721. _OrderBy(expression, type);
  3722. return this;
  3723. }
  3724. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
  3725. {
  3726. _OrderBy(expression, type);
  3727. return this;
  3728. }
  3729. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc)
  3730. {
  3731. _OrderBy(expression, type);
  3732. return this;
  3733. }
  3734. #endregion
  3735. #region GroupBy
  3736. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, object>> expression)
  3737. {
  3738. _GroupBy(expression);
  3739. return this;
  3740. }
  3741. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, object>> expression)
  3742. {
  3743. _GroupBy(expression);
  3744. return this;
  3745. }
  3746. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  3747. {
  3748. _GroupBy(expression);
  3749. return this;
  3750. }
  3751. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  3752. {
  3753. _GroupBy(expression);
  3754. return this;
  3755. }
  3756. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  3757. {
  3758. _GroupBy(expression);
  3759. return this;
  3760. }
  3761. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  3762. {
  3763. _GroupBy(expression);
  3764. return this;
  3765. }
  3766. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression)
  3767. {
  3768. _GroupBy(expression);
  3769. return this;
  3770. }
  3771. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression)
  3772. {
  3773. _GroupBy(expression);
  3774. return this;
  3775. }
  3776. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression)
  3777. {
  3778. _GroupBy(expression);
  3779. return this;
  3780. }
  3781. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression)
  3782. {
  3783. _GroupBy(expression);
  3784. return this;
  3785. }
  3786. #endregion
  3787. #region Aggr
  3788. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  3789. {
  3790. return _Max<TResult>(expression);
  3791. }
  3792. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  3793. {
  3794. return _Min<TResult>(expression);
  3795. }
  3796. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  3797. {
  3798. return _Sum<TResult>(expression);
  3799. }
  3800. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  3801. {
  3802. return _Avg<TResult>(expression);
  3803. }
  3804. #endregion
  3805. #region In
  3806. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  3807. {
  3808. var isSingle = QueryBuilder.IsSingle();
  3809. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  3810. var fieldName = lamResult.GetResultString();
  3811. In(fieldName, inValues);
  3812. return this;
  3813. }
  3814. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  3815. {
  3816. var isSingle = QueryBuilder.IsSingle();
  3817. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  3818. var fieldName = lamResult.GetResultString();
  3819. In(fieldName, inValues);
  3820. return this;
  3821. }
  3822. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  3823. {
  3824. var sqlObj = childQueryExpression.ToSql();
  3825. _InQueryable(expression, sqlObj);
  3826. return this;
  3827. }
  3828. #endregion
  3829. #region Other
  3830. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AS<AsT>(string tableName)
  3831. {
  3832. var entityName = typeof(AsT).Name;
  3833. _As(tableName, entityName);
  3834. return this;
  3835. }
  3836. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AS(string tableName)
  3837. {
  3838. var entityName = typeof(T).Name;
  3839. _As(tableName, entityName);
  3840. return this;
  3841. }
  3842. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Filter(string FilterName, bool isDisabledGobalFilter = false)
  3843. {
  3844. _Filter(FilterName, isDisabledGobalFilter);
  3845. return this;
  3846. }
  3847. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AddParameters(object parameters)
  3848. {
  3849. if (parameters != null)
  3850. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  3851. return this;
  3852. }
  3853. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AddParameters(SugarParameter[] parameters)
  3854. {
  3855. if (parameters != null)
  3856. QueryBuilder.Parameters.AddRange(parameters);
  3857. return this;
  3858. }
  3859. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AddParameters(List<SugarParameter> parameters)
  3860. {
  3861. if (parameters != null)
  3862. QueryBuilder.Parameters.AddRange(parameters);
  3863. return this;
  3864. }
  3865. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  3866. {
  3867. QueryBuilder.JoinIndex = +1;
  3868. QueryBuilder.JoinQueryInfos
  3869. .Add(new JoinQueryInfo
  3870. {
  3871. JoinIndex = QueryBuilder.JoinIndex,
  3872. TableName = tableName,
  3873. ShortName = shortName,
  3874. JoinType = type,
  3875. JoinWhere = joinWhere
  3876. });
  3877. return this;
  3878. }
  3879. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> With(string withString)
  3880. {
  3881. base.With(withString);
  3882. return this;
  3883. }
  3884. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCache(int cacheDurationInSeconds = int.MaxValue)
  3885. {
  3886. this.IsCache = true;
  3887. this.CacheTime = cacheDurationInSeconds;
  3888. return this;
  3889. }
  3890. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  3891. {
  3892. if (IsCache)
  3893. {
  3894. this.IsCache = true;
  3895. this.CacheTime = cacheDurationInSeconds;
  3896. }
  3897. return this;
  3898. }
  3899. #endregion
  3900. }
  3901. #endregion
  3902. #region T11
  3903. public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
  3904. {
  3905. #region Where
  3906. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, bool>> expression)
  3907. {
  3908. _Where(expression);
  3909. return this;
  3910. }
  3911. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, bool>> expression)
  3912. {
  3913. _Where(expression);
  3914. return this;
  3915. }
  3916. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, bool>> expression)
  3917. {
  3918. _Where(expression);
  3919. return this;
  3920. }
  3921. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  3922. {
  3923. _Where(expression);
  3924. return this;
  3925. }
  3926. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  3927. {
  3928. _Where(expression);
  3929. return this;
  3930. }
  3931. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  3932. {
  3933. _Where(expression);
  3934. return this;
  3935. }
  3936. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  3937. {
  3938. _Where(expression);
  3939. return this;
  3940. }
  3941. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  3942. {
  3943. _Where(expression);
  3944. return this;
  3945. }
  3946. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  3947. {
  3948. _Where(expression);
  3949. return this;
  3950. }
  3951. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
  3952. {
  3953. _Where(expression);
  3954. return this;
  3955. }
  3956. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> expression)
  3957. {
  3958. _Where(expression);
  3959. return this;
  3960. }
  3961. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  3962. {
  3963. if (isWhere)
  3964. _Where(expression);
  3965. return this;
  3966. }
  3967. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(List<IConditionalModel> conditionalModels)
  3968. {
  3969. base.Where(conditionalModels);
  3970. return this;
  3971. }
  3972. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  3973. {
  3974. if (isWhere)
  3975. _Where(expression);
  3976. return this;
  3977. }
  3978. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  3979. {
  3980. if (isWhere)
  3981. _Where(expression);
  3982. return this;
  3983. }
  3984. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  3985. {
  3986. if (isWhere)
  3987. _Where(expression);
  3988. return this;
  3989. }
  3990. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  3991. {
  3992. if (isWhere)
  3993. _Where(expression);
  3994. return this;
  3995. }
  3996. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  3997. {
  3998. if (isWhere)
  3999. _Where(expression);
  4000. return this;
  4001. }
  4002. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  4003. {
  4004. if (isWhere)
  4005. _Where(expression);
  4006. return this;
  4007. }
  4008. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  4009. {
  4010. if (isWhere)
  4011. _Where(expression);
  4012. return this;
  4013. }
  4014. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  4015. {
  4016. if (isWhere)
  4017. _Where(expression);
  4018. return this;
  4019. }
  4020. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
  4021. {
  4022. if (isWhere)
  4023. _Where(expression);
  4024. return this;
  4025. }
  4026. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> expression)
  4027. {
  4028. if (isWhere)
  4029. _Where(expression);
  4030. return this;
  4031. }
  4032. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Where(string whereString, object whereObj)
  4033. {
  4034. Where<T>(whereString, whereObj);
  4035. return this;
  4036. }
  4037. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WhereIF(bool isWhere, string whereString, object whereObj)
  4038. {
  4039. if (!isWhere) return this;
  4040. this.Where<T>(whereString, whereObj);
  4041. return this;
  4042. }
  4043. #endregion
  4044. #region Select
  4045. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  4046. {
  4047. return _Select<TResult>(expression);
  4048. }
  4049. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  4050. {
  4051. return _Select<TResult>(expression);
  4052. }
  4053. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  4054. {
  4055. return _Select<TResult>(expression);
  4056. }
  4057. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  4058. {
  4059. return _Select<TResult>(expression);
  4060. }
  4061. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  4062. {
  4063. return _Select<TResult>(expression);
  4064. }
  4065. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  4066. {
  4067. return _Select<TResult>(expression);
  4068. }
  4069. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  4070. {
  4071. return _Select<TResult>(expression);
  4072. }
  4073. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  4074. {
  4075. return _Select<TResult>(expression);
  4076. }
  4077. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  4078. {
  4079. return _Select<TResult>(expression);
  4080. }
  4081. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
  4082. {
  4083. return _Select<TResult>(expression);
  4084. }
  4085. #endregion
  4086. #region OrderBy
  4087. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  4088. {
  4089. _OrderBy(expression, type);
  4090. return this;
  4091. }
  4092. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  4093. {
  4094. _OrderBy(expression, type);
  4095. return this;
  4096. }
  4097. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  4098. {
  4099. _OrderBy(expression, type);
  4100. return this;
  4101. }
  4102. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  4103. {
  4104. _OrderBy(expression, type);
  4105. return this;
  4106. }
  4107. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  4108. {
  4109. _OrderBy(expression, type);
  4110. return this;
  4111. }
  4112. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  4113. {
  4114. _OrderBy(expression, type);
  4115. return this;
  4116. }
  4117. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
  4118. {
  4119. _OrderBy(expression, type);
  4120. return this;
  4121. }
  4122. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
  4123. {
  4124. _OrderBy(expression, type);
  4125. return this;
  4126. }
  4127. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
  4128. {
  4129. _OrderBy(expression, type);
  4130. return this;
  4131. }
  4132. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc)
  4133. {
  4134. _OrderBy(expression, type);
  4135. return this;
  4136. }
  4137. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc)
  4138. {
  4139. _OrderBy(expression, type);
  4140. return this;
  4141. }
  4142. #endregion
  4143. #region GroupBy
  4144. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, object>> expression)
  4145. {
  4146. _GroupBy(expression);
  4147. return this;
  4148. }
  4149. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, object>> expression)
  4150. {
  4151. _GroupBy(expression);
  4152. return this;
  4153. }
  4154. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  4155. {
  4156. _GroupBy(expression);
  4157. return this;
  4158. }
  4159. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  4160. {
  4161. _GroupBy(expression);
  4162. return this;
  4163. }
  4164. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  4165. {
  4166. _GroupBy(expression);
  4167. return this;
  4168. }
  4169. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  4170. {
  4171. _GroupBy(expression);
  4172. return this;
  4173. }
  4174. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression)
  4175. {
  4176. _GroupBy(expression);
  4177. return this;
  4178. }
  4179. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression)
  4180. {
  4181. _GroupBy(expression);
  4182. return this;
  4183. }
  4184. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression)
  4185. {
  4186. _GroupBy(expression);
  4187. return this;
  4188. }
  4189. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression)
  4190. {
  4191. _GroupBy(expression);
  4192. return this;
  4193. }
  4194. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression)
  4195. {
  4196. _GroupBy(expression);
  4197. return this;
  4198. }
  4199. #endregion
  4200. #region Aggr
  4201. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
  4202. {
  4203. return _Max<TResult>(expression);
  4204. }
  4205. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
  4206. {
  4207. return _Min<TResult>(expression);
  4208. }
  4209. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
  4210. {
  4211. return _Sum<TResult>(expression);
  4212. }
  4213. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
  4214. {
  4215. return _Avg<TResult>(expression);
  4216. }
  4217. #endregion
  4218. #region In
  4219. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  4220. {
  4221. var isSingle = QueryBuilder.IsSingle();
  4222. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  4223. var fieldName = lamResult.GetResultString();
  4224. In(fieldName, inValues);
  4225. return this;
  4226. }
  4227. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  4228. {
  4229. var isSingle = QueryBuilder.IsSingle();
  4230. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  4231. var fieldName = lamResult.GetResultString();
  4232. In(fieldName, inValues);
  4233. return this;
  4234. }
  4235. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  4236. {
  4237. var sqlObj = childQueryExpression.ToSql();
  4238. _InQueryable(expression, sqlObj);
  4239. return this;
  4240. }
  4241. #endregion
  4242. #region Other
  4243. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AS<AsT>(string tableName)
  4244. {
  4245. var entityName = typeof(AsT).Name;
  4246. _As(tableName, entityName);
  4247. return this;
  4248. }
  4249. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AS(string tableName)
  4250. {
  4251. var entityName = typeof(T).Name;
  4252. _As(tableName, entityName);
  4253. return this;
  4254. }
  4255. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Filter(string FilterName, bool isDisabledGobalFilter = false)
  4256. {
  4257. _Filter(FilterName, isDisabledGobalFilter);
  4258. return this;
  4259. }
  4260. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AddParameters(object parameters)
  4261. {
  4262. if (parameters != null)
  4263. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  4264. return this;
  4265. }
  4266. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AddParameters(SugarParameter[] parameters)
  4267. {
  4268. if (parameters != null)
  4269. QueryBuilder.Parameters.AddRange(parameters);
  4270. return this;
  4271. }
  4272. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AddParameters(List<SugarParameter> parameters)
  4273. {
  4274. if (parameters != null)
  4275. QueryBuilder.Parameters.AddRange(parameters);
  4276. return this;
  4277. }
  4278. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  4279. {
  4280. QueryBuilder.JoinIndex = +1;
  4281. QueryBuilder.JoinQueryInfos
  4282. .Add(new JoinQueryInfo
  4283. {
  4284. JoinIndex = QueryBuilder.JoinIndex,
  4285. TableName = tableName,
  4286. ShortName = shortName,
  4287. JoinType = type,
  4288. JoinWhere = joinWhere
  4289. });
  4290. return this;
  4291. }
  4292. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> With(string withString)
  4293. {
  4294. base.With(withString);
  4295. return this;
  4296. }
  4297. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCache(int cacheDurationInSeconds = int.MaxValue)
  4298. {
  4299. this.IsCache = true;
  4300. this.CacheTime = cacheDurationInSeconds;
  4301. return this;
  4302. }
  4303. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  4304. {
  4305. if (IsCache)
  4306. {
  4307. this.IsCache = true;
  4308. this.CacheTime = cacheDurationInSeconds;
  4309. }
  4310. return this;
  4311. }
  4312. #endregion
  4313. }
  4314. #endregion
  4315. #region T12
  4316. public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
  4317. {
  4318. #region Where
  4319. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, bool>> expression)
  4320. {
  4321. _Where(expression);
  4322. return this;
  4323. }
  4324. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, bool>> expression)
  4325. {
  4326. _Where(expression);
  4327. return this;
  4328. }
  4329. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, bool>> expression)
  4330. {
  4331. _Where(expression);
  4332. return this;
  4333. }
  4334. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, bool>> expression)
  4335. {
  4336. _Where(expression);
  4337. return this;
  4338. }
  4339. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  4340. {
  4341. _Where(expression);
  4342. return this;
  4343. }
  4344. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  4345. {
  4346. _Where(expression);
  4347. return this;
  4348. }
  4349. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  4350. {
  4351. _Where(expression);
  4352. return this;
  4353. }
  4354. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  4355. {
  4356. _Where(expression);
  4357. return this;
  4358. }
  4359. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  4360. {
  4361. _Where(expression);
  4362. return this;
  4363. }
  4364. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
  4365. {
  4366. _Where(expression);
  4367. return this;
  4368. }
  4369. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> expression)
  4370. {
  4371. _Where(expression);
  4372. return this;
  4373. }
  4374. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> expression)
  4375. {
  4376. _Where(expression);
  4377. return this;
  4378. }
  4379. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(List<IConditionalModel> conditionalModels)
  4380. {
  4381. base.Where(conditionalModels);
  4382. return this;
  4383. }
  4384. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
  4385. {
  4386. if (isWhere)
  4387. _Where(expression);
  4388. return this;
  4389. }
  4390. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression)
  4391. {
  4392. if (isWhere)
  4393. _Where(expression);
  4394. return this;
  4395. }
  4396. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression)
  4397. {
  4398. if (isWhere)
  4399. _Where(expression);
  4400. return this;
  4401. }
  4402. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression)
  4403. {
  4404. if (isWhere)
  4405. _Where(expression);
  4406. return this;
  4407. }
  4408. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression)
  4409. {
  4410. if (isWhere)
  4411. _Where(expression);
  4412. return this;
  4413. }
  4414. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression)
  4415. {
  4416. if (isWhere)
  4417. _Where(expression);
  4418. return this;
  4419. }
  4420. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression)
  4421. {
  4422. if (isWhere)
  4423. _Where(expression);
  4424. return this;
  4425. }
  4426. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression)
  4427. {
  4428. if (isWhere)
  4429. _Where(expression);
  4430. return this;
  4431. }
  4432. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> expression)
  4433. {
  4434. if (isWhere)
  4435. _Where(expression);
  4436. return this;
  4437. }
  4438. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> expression)
  4439. {
  4440. if (isWhere)
  4441. _Where(expression);
  4442. return this;
  4443. }
  4444. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> expression)
  4445. {
  4446. if (isWhere)
  4447. _Where(expression);
  4448. return this;
  4449. }
  4450. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> expression)
  4451. {
  4452. if (isWhere)
  4453. _Where(expression);
  4454. return this;
  4455. }
  4456. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Where(string whereString, object whereObj)
  4457. {
  4458. Where<T>(whereString, whereObj);
  4459. return this;
  4460. }
  4461. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WhereIF(bool isWhere, string whereString, object whereObj)
  4462. {
  4463. if (!isWhere) return this;
  4464. this.Where<T>(whereString, whereObj);
  4465. return this;
  4466. }
  4467. #endregion
  4468. #region Select
  4469. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, TResult>> expression)
  4470. {
  4471. return _Select<TResult>(expression);
  4472. }
  4473. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, TResult>> expression)
  4474. {
  4475. return _Select<TResult>(expression);
  4476. }
  4477. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, TResult>> expression)
  4478. {
  4479. return _Select<TResult>(expression);
  4480. }
  4481. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
  4482. {
  4483. return _Select<TResult>(expression);
  4484. }
  4485. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, TResult>> expression)
  4486. {
  4487. return _Select<TResult>(expression);
  4488. }
  4489. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, TResult>> expression)
  4490. {
  4491. return _Select<TResult>(expression);
  4492. }
  4493. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, TResult>> expression)
  4494. {
  4495. return _Select<TResult>(expression);
  4496. }
  4497. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, TResult>> expression)
  4498. {
  4499. return _Select<TResult>(expression);
  4500. }
  4501. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>> expression)
  4502. {
  4503. return _Select<TResult>(expression);
  4504. }
  4505. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>> expression)
  4506. {
  4507. return _Select<TResult>(expression);
  4508. }
  4509. public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>> expression)
  4510. {
  4511. return _Select<TResult>(expression);
  4512. }
  4513. #endregion
  4514. #region OrderBy
  4515. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
  4516. {
  4517. _OrderBy(expression, type);
  4518. return this;
  4519. }
  4520. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
  4521. {
  4522. _OrderBy(expression, type);
  4523. return this;
  4524. }
  4525. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
  4526. {
  4527. _OrderBy(expression, type);
  4528. return this;
  4529. }
  4530. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
  4531. {
  4532. _OrderBy(expression, type);
  4533. return this;
  4534. }
  4535. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
  4536. {
  4537. _OrderBy(expression, type);
  4538. return this;
  4539. }
  4540. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
  4541. {
  4542. _OrderBy(expression, type);
  4543. return this;
  4544. }
  4545. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
  4546. {
  4547. _OrderBy(expression, type);
  4548. return this;
  4549. }
  4550. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
  4551. {
  4552. _OrderBy(expression, type);
  4553. return this;
  4554. }
  4555. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
  4556. {
  4557. _OrderBy(expression, type);
  4558. return this;
  4559. }
  4560. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc)
  4561. {
  4562. _OrderBy(expression, type);
  4563. return this;
  4564. }
  4565. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc)
  4566. {
  4567. _OrderBy(expression, type);
  4568. return this;
  4569. }
  4570. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object>> expression, OrderByType type = OrderByType.Asc)
  4571. {
  4572. _OrderBy(expression, type);
  4573. return this;
  4574. }
  4575. #endregion
  4576. #region GroupBy
  4577. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, object>> expression)
  4578. {
  4579. _GroupBy(expression);
  4580. return this;
  4581. }
  4582. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, object>> expression)
  4583. {
  4584. _GroupBy(expression);
  4585. return this;
  4586. }
  4587. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, object>> expression)
  4588. {
  4589. _GroupBy(expression);
  4590. return this;
  4591. }
  4592. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, object>> expression)
  4593. {
  4594. _GroupBy(expression);
  4595. return this;
  4596. }
  4597. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, object>> expression)
  4598. {
  4599. _GroupBy(expression);
  4600. return this;
  4601. }
  4602. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, object>> expression)
  4603. {
  4604. _GroupBy(expression);
  4605. return this;
  4606. }
  4607. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression)
  4608. {
  4609. _GroupBy(expression);
  4610. return this;
  4611. }
  4612. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression)
  4613. {
  4614. _GroupBy(expression);
  4615. return this;
  4616. }
  4617. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression)
  4618. {
  4619. _GroupBy(expression);
  4620. return this;
  4621. }
  4622. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression)
  4623. {
  4624. _GroupBy(expression);
  4625. return this;
  4626. }
  4627. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression)
  4628. {
  4629. _GroupBy(expression);
  4630. return this;
  4631. }
  4632. public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> GroupBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object>> expression)
  4633. {
  4634. _GroupBy(expression);
  4635. return this;
  4636. }
  4637. #endregion
  4638. #region Aggr
  4639. public TResult Max<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>> expression)
  4640. {
  4641. return _Max<TResult>(expression);
  4642. }
  4643. public TResult Min<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>> expression)
  4644. {
  4645. return _Min<TResult>(expression);
  4646. }
  4647. public TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>> expression)
  4648. {
  4649. return _Sum<TResult>(expression);
  4650. }
  4651. public TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>> expression)
  4652. {
  4653. return _Avg<TResult>(expression);
  4654. }
  4655. #endregion
  4656. #region In
  4657. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
  4658. {
  4659. var isSingle = QueryBuilder.IsSingle();
  4660. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  4661. var fieldName = lamResult.GetResultString();
  4662. In(fieldName, inValues);
  4663. return this;
  4664. }
  4665. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
  4666. {
  4667. var isSingle = QueryBuilder.IsSingle();
  4668. var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
  4669. var fieldName = lamResult.GetResultString();
  4670. In(fieldName, inValues);
  4671. return this;
  4672. }
  4673. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
  4674. {
  4675. var sqlObj = childQueryExpression.ToSql();
  4676. _InQueryable(expression, sqlObj);
  4677. return this;
  4678. }
  4679. #endregion
  4680. #region Other
  4681. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AS<AsT>(string tableName)
  4682. {
  4683. var entityName = typeof(AsT).Name;
  4684. _As(tableName, entityName);
  4685. return this;
  4686. }
  4687. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AS(string tableName)
  4688. {
  4689. var entityName = typeof(T).Name;
  4690. _As(tableName, entityName);
  4691. return this;
  4692. }
  4693. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Filter(string FilterName, bool isDisabledGobalFilter = false)
  4694. {
  4695. _Filter(FilterName, isDisabledGobalFilter);
  4696. return this;
  4697. }
  4698. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AddParameters(object parameters)
  4699. {
  4700. if (parameters != null)
  4701. QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(parameters));
  4702. return this;
  4703. }
  4704. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AddParameters(SugarParameter[] parameters)
  4705. {
  4706. if (parameters != null)
  4707. QueryBuilder.Parameters.AddRange(parameters);
  4708. return this;
  4709. }
  4710. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AddParameters(List<SugarParameter> parameters)
  4711. {
  4712. if (parameters != null)
  4713. QueryBuilder.Parameters.AddRange(parameters);
  4714. return this;
  4715. }
  4716. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type = JoinType.Left)
  4717. {
  4718. QueryBuilder.JoinIndex = +1;
  4719. QueryBuilder.JoinQueryInfos
  4720. .Add(new JoinQueryInfo
  4721. {
  4722. JoinIndex = QueryBuilder.JoinIndex,
  4723. TableName = tableName,
  4724. ShortName = shortName,
  4725. JoinType = type,
  4726. JoinWhere = joinWhere
  4727. });
  4728. return this;
  4729. }
  4730. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> With(string withString)
  4731. {
  4732. base.With(withString);
  4733. return this;
  4734. }
  4735. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds = int.MaxValue)
  4736. {
  4737. this.IsCache = true;
  4738. this.CacheTime = cacheDurationInSeconds;
  4739. return this;
  4740. }
  4741. public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
  4742. {
  4743. if (IsCache)
  4744. {
  4745. this.IsCache = true;
  4746. this.CacheTime = cacheDurationInSeconds;
  4747. }
  4748. return this;
  4749. }
  4750. #endregion
  4751. }
  4752. #endregion
  4753. }