PageRenderTime 60ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/examples/EFTester/Acme.TestModel/Business/Objects/SimpleCollection.Generated.cs

#
C# | 1394 lines | 814 code | 140 blank | 440 comment | 94 complexity | 2ac60b7c384fce52e79dadf59b4015e0 MD5 | raw file
Possible License(s): JSON, CC-BY-SA-3.0

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Data;
  3. using System.Xml;
  4. using System.Collections;
  5. using System.Runtime.Serialization;
  6. using System.ComponentModel;
  7. using Acme.TestModel.Business.Rules;
  8. using Acme.TestModel.Business.SelectCommands;
  9. using Acme.TestModel.Domain.Objects;
  10. using Widgetsphere.Core.DataAccess;
  11. using Widgetsphere.Core.Util;
  12. using Widgetsphere.Core.Logging;
  13. using Widgetsphere.Core.Exceptions;
  14. using Acme.TestModel.Business.LINQ;
  15. using System.IO;
  16. using System.Collections.Generic;
  17. using System.Linq.Expressions;
  18. using System.Data.Linq;
  19. using System.Linq;
  20. using System.Text;
  21. using Widgetsphere.Core.EventArgs;
  22. using System.Text.RegularExpressions;
  23. namespace Acme.TestModel.Business.Objects
  24. {
  25. /// <summary>
  26. /// The collection to hold 'Simple' entities
  27. /// </summary>
  28. [Serializable()]
  29. public partial class SimpleCollection : Widgetsphere.Core.DataAccess.BusinessCollectionPersistableBase, Widgetsphere.Core.DataAccess.IPersistableBusinessCollection, System.IDisposable, System.ComponentModel.IListSource, System.Collections.IList, System.Collections.IEnumerator, System.Collections.Generic.IEnumerable<Acme.TestModel.Business.Objects.Simple>, Widgetsphere.Core.DataAccess.IWrappingClass
  30. {
  31. #region Member Variables
  32. internal DomainSimpleCollection wrappedClass;
  33. /// <summary>
  34. /// The parent subdomain object
  35. /// </summary>
  36. protected SubDomain _subDomain = null;
  37. #endregion
  38. #region Constructor / Initialize
  39. internal SimpleCollection(DomainSimpleCollection classToWrap)
  40. {
  41. _subDomain = classToWrap.SubDomain;
  42. wrappedClass = classToWrap;
  43. }
  44. /// <summary>
  45. /// Constructor that enables you to specify a modifier
  46. /// </summary>
  47. /// <param name="modifier">Used in audit operations to track changes</param>
  48. public SimpleCollection(string modifier)
  49. {
  50. _subDomain = new SubDomain(modifier);
  51. ResetWrappedClass((DomainSimpleCollection)_subDomain.GetDomainCollection(Collections.SimpleCollection));
  52. }
  53. /// <summary>
  54. /// The default constructor
  55. /// </summary>
  56. public SimpleCollection()
  57. {
  58. _subDomain = new SubDomain(ConfigurationValues.GetInstance().Modifier);
  59. ResetWrappedClass((DomainSimpleCollection)_subDomain.GetDomainCollection(Collections.SimpleCollection));
  60. }
  61. #endregion
  62. #region Property Implementations
  63. /// <summary>
  64. /// Returns the internal object that this object wraps
  65. /// </summary>
  66. [System.ComponentModel.Browsable(false)]
  67. internal virtual object WrappedClass
  68. {
  69. get { return wrappedClass ; }
  70. set { wrappedClass = (DomainSimpleCollection)value ; }
  71. }
  72. //WrappingClass Interface
  73. object Widgetsphere.Core.DataAccess.IWrappingClass.WrappedClass
  74. {
  75. get { return this.WrappedClass; }
  76. set { this.WrappedClass = value; }
  77. }
  78. /// <summary>
  79. /// Specifies a modifier string to be used in the audit functionality
  80. /// </summary>
  81. public string Modifier
  82. {
  83. get
  84. {
  85. try
  86. {
  87. return wrappedClass.Modifier;
  88. }
  89. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  90. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  91. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  92. }
  93. internal set { wrappedClass.Modifier = value; }
  94. }
  95. /// <summary>
  96. /// A reference to the SubDomain that holds this collection
  97. /// </summary>
  98. public SubDomain SubDomain
  99. {
  100. get
  101. {
  102. try
  103. {
  104. return wrappedClass.SubDomain;
  105. }
  106. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  107. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  108. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  109. }
  110. }
  111. /// <summary>
  112. /// Returns the number of items in this collection
  113. /// </summary>
  114. public override int Count
  115. {
  116. get
  117. {
  118. try
  119. {
  120. lock (wrappedClass.SubDomain)
  121. {
  122. DataTable dt = wrappedClass.GetChanges(DataRowState.Deleted);
  123. if (dt == null) return wrappedClass.Count;
  124. else return wrappedClass.Count - dt.Rows.Count;
  125. }
  126. }
  127. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  128. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  129. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  130. }
  131. }
  132. /// <summary>
  133. /// Determines the type of object contained by this collection.
  134. /// </summary>
  135. public virtual Type ContainedType
  136. {
  137. get { return typeof(Simple); }
  138. }
  139. /// <summary>
  140. /// Determines the type of collection for this object.
  141. /// </summary>
  142. public virtual Collections Collection
  143. {
  144. get { return Collections.SimpleCollection; }
  145. }
  146. #endregion
  147. #region Enumerator
  148. /// <summary>
  149. /// Gets or sets the element at the specified index.
  150. /// </summary>
  151. /// <param name="index">The zero-based index of the element to get or set. </param>
  152. /// <returns>The element at the specified index.</returns>
  153. public virtual Simple this[int index]
  154. {
  155. get
  156. {
  157. try
  158. {
  159. var internalEnumerator = this.GetEnumerator();
  160. internalEnumerator.Reset();
  161. int ii = -1;
  162. while(ii < index)
  163. {
  164. internalEnumerator.MoveNext();
  165. ii++;
  166. }
  167. var retval = (Simple)internalEnumerator.Current;
  168. if (retval.wrappedClass == null)
  169. {
  170. if (!((0 <= index) && (index < this.Count)))
  171. throw new IndexOutOfRangeException();
  172. else
  173. throw new Exception("The item is null. This is not a valid state.");
  174. }
  175. else return (Simple)internalEnumerator.Current;
  176. }
  177. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  178. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  179. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  180. }
  181. }
  182. #endregion
  183. #region Methods
  184. /// <summary>
  185. /// Create a new object to later add to this collection
  186. /// </summary>
  187. public virtual Simple NewItem(int SimpleId)
  188. {
  189. try
  190. {
  191. lock (wrappedClass.SubDomain)
  192. {
  193. return new Simple(wrappedClass.NewItem(SimpleId));
  194. }
  195. }
  196. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  197. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  198. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  199. }
  200. /// <summary>
  201. /// Create a new object to later add to this collection
  202. /// </summary>
  203. public virtual Simple NewItem()
  204. {
  205. try
  206. {
  207. lock (wrappedClass.SubDomain)
  208. {
  209. return new Simple(wrappedClass.NewItem());
  210. }
  211. }
  212. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  213. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  214. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  215. }
  216. /// <summary>
  217. /// Add a newly created entity to this collection.
  218. /// </summary>
  219. public virtual void AddItem(Simple item)
  220. {
  221. try
  222. {
  223. lock (wrappedClass.SubDomain)
  224. {
  225. wrappedClass.AddItem((DomainSimple)item.WrappedClass);
  226. }
  227. }
  228. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  229. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  230. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  231. }
  232. /// <summary>
  233. /// Determines if the specified item exists in this list
  234. /// </summary>
  235. /// <param name="item"></param>
  236. /// <returns></returns>
  237. public virtual bool Contains(Acme.TestModel.Business.Objects.Simple item)
  238. {
  239. foreach (var o in this)
  240. {
  241. if (o == item) return true;
  242. }
  243. return false;
  244. }
  245. /// <summary>
  246. /// Determines the position in the list of the specified item, if it exists
  247. /// </summary>
  248. /// <param name="item"></param>
  249. /// <returns></returns>
  250. public virtual int IndexOf(Acme.TestModel.Business.Objects.Simple item)
  251. {
  252. int index = 0;
  253. foreach (var o in this)
  254. {
  255. if (o == item) return index;
  256. index++;
  257. }
  258. return -1;
  259. }
  260. #region IListSource Members
  261. bool System.ComponentModel.IListSource.ContainsListCollection
  262. {
  263. get { return true; }
  264. }
  265. System.Collections.IList System.ComponentModel.IListSource.GetList()
  266. {
  267. var list = new System.Collections.Generic.List<Acme.TestModel.Business.Objects.Simple>();
  268. list.AddRange(this);
  269. return list;
  270. }
  271. #endregion
  272. #region IList Members
  273. int System.Collections.IList.Add(object value)
  274. {
  275. if (!(value is Acme.TestModel.Business.Objects.Simple))
  276. throw new System.Exception("The specified type is not valid!");
  277. var item = value as Acme.TestModel.Business.Objects.Simple;
  278. this.AddItem(item);
  279. return this.Count;
  280. }
  281. void System.Collections.IList.Clear()
  282. {
  283. throw new System.NotImplementedException();
  284. }
  285. bool System.Collections.IList.Contains(object value)
  286. {
  287. if (!(value is Acme.TestModel.Business.Objects.Simple))
  288. throw new System.Exception("The specified type is not valid!");
  289. var item = value as Acme.TestModel.Business.Objects.Simple;
  290. return this.Contains(item);
  291. }
  292. int System.Collections.IList.IndexOf(object value)
  293. {
  294. if (!(value is Acme.TestModel.Business.Objects.Simple))
  295. throw new System.Exception("The specified type is not valid!");
  296. var item = value as Acme.TestModel.Business.Objects.Simple;
  297. return this.IndexOf(item);
  298. }
  299. void System.Collections.IList.Insert(int index, object value)
  300. {
  301. throw new System.NotImplementedException();
  302. }
  303. bool System.Collections.IList.IsFixedSize
  304. {
  305. get { return false; }
  306. }
  307. bool System.Collections.IList.IsReadOnly
  308. {
  309. get { return false; }
  310. }
  311. void System.Collections.IList.Remove(object value)
  312. {
  313. if (!(value is Acme.TestModel.Business.Objects.Simple))
  314. throw new System.Exception("The specified type is not valid!");
  315. var item = value as Acme.TestModel.Business.Objects.Simple;
  316. if (this.Contains(item))
  317. item.Delete();
  318. }
  319. void System.Collections.IList.RemoveAt(int index)
  320. {
  321. if ((0 <= index) && (index < this.Count))
  322. this[index].Delete();
  323. }
  324. object System.Collections.IList.this[int index]
  325. {
  326. get { return this[index]; }
  327. set { throw new System.NotImplementedException(); }
  328. }
  329. #endregion
  330. /// <summary>
  331. /// Takes an IVisitor object and iterates through each item in this collection
  332. /// </summary>
  333. /// <param name="visitor">The object that processes each collection item</param>
  334. public virtual void ProcessVisitor(IVisitor visitor)
  335. {
  336. if (visitor == null) throw new Exception("This object cannot be null.");
  337. lock(this)
  338. {
  339. foreach (IBusinessObject item in this)
  340. {
  341. visitor.Visit(item);
  342. }
  343. }
  344. }
  345. #region Static SQL Methods
  346. internal static string GetFieldAliasFromFieldNameSqlMapping(string alias)
  347. {
  348. alias = alias.Replace("[", string.Empty).Replace("]", string.Empty);
  349. switch (alias.ToLower())
  350. {
  351. case "my_readonly": return "myreadonly";
  352. case "name": return "name";
  353. case "new_int": return "newint";
  354. case "simple_id": return "simpleid";
  355. case "created_date": return "createddate";
  356. case "created_by": return "createdby";
  357. case "modified_date": return "modifieddate";
  358. case "modified_by": return "modifiedby";
  359. case "time_stamp": return "timestamp";
  360. default: throw new Exception("The select clause is not valid.");
  361. }
  362. }
  363. internal static string GetTableFromFieldAliasSqlMapping(string alias)
  364. {
  365. switch (alias.ToLower())
  366. {
  367. case "myreadonly": return "SIMPLE";
  368. case "name": return "SIMPLE";
  369. case "newint": return "SIMPLE";
  370. case "simpleid": return "SIMPLE";
  371. case "createdby": return "SIMPLE";
  372. case "createddate": return "SIMPLE";
  373. case "modifiedby": return "SIMPLE";
  374. case "modifieddate": return "SIMPLE";
  375. case "timestamp": return "SIMPLE";
  376. default: throw new Exception("The select clause is not valid.");
  377. }
  378. }
  379. internal static string GetTableFromFieldNameSqlMapping(string field)
  380. {
  381. switch (field.ToLower())
  382. {
  383. case "my_readonly": return "SIMPLE";
  384. case "name": return "SIMPLE";
  385. case "new_int": return "SIMPLE";
  386. case "simple_id": return "SIMPLE";
  387. case "created_by": return "SIMPLE";
  388. case "created_date": return "SIMPLE";
  389. case "modified_by": return "SIMPLE";
  390. case "modified_date": return "SIMPLE";
  391. case "time_stamp": return "SIMPLE";
  392. default: throw new Exception("The select clause is not valid.");
  393. }
  394. }
  395. internal static string GetRemappedLinqSql(string sql, string parentAlias, LinqSQLFromClauseCollection childTables)
  396. {
  397. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[my_readonly\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[my_readonly]", RegexOptions.IgnoreCase);
  398. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[name\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[name]", RegexOptions.IgnoreCase);
  399. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[new_int\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[new_int]", RegexOptions.IgnoreCase);
  400. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[simple_id\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[simple_id]", RegexOptions.IgnoreCase);
  401. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[createdby\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[createdby]", RegexOptions.IgnoreCase);
  402. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[createddate\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[createddate]", RegexOptions.IgnoreCase);
  403. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[modifiedby\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[modifiedby]", RegexOptions.IgnoreCase);
  404. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[modifieddate\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[modifieddate]", RegexOptions.IgnoreCase);
  405. sql = System.Text.RegularExpressions.Regex.Replace(sql, "\\[" + parentAlias + "\\]\\.\\[timestamp\\]", "[" + childTables.GetBaseAliasTable(parentAlias, "SIMPLE") + "].[timestamp]", RegexOptions.IgnoreCase);
  406. return sql;
  407. }
  408. internal static string GetPagedSQL(List<LinqSQLField> fieldList, LinqSQLFromClauseCollection fromLinkList, string whereClause, object paging, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  409. {
  410. var sb = new StringBuilder();
  411. var paging2 = (SimplePaging)paging;
  412. //Calculate the SELECT clause
  413. sb.Append("SELECT ");
  414. int index = 0;
  415. foreach (LinqSQLField field in fieldList)
  416. {
  417. sb.Append("[t0].[" + field.Name + "]");
  418. if (index < fieldList.Count - 1) sb.Append(", ");
  419. index++;
  420. }
  421. sb.AppendLine();
  422. sb.AppendLine("FROM (");
  423. //Calculate the Inner SELECT clause
  424. sb.Append("SELECT ");
  425. index = 0;
  426. foreach (var field in fieldList)
  427. {
  428. sb.Append(field.GetSQL(false));
  429. if (index < fieldList.Count - 1) sb.Append(", ");
  430. index++;
  431. }
  432. sb.AppendLine();
  433. //If there is no sort then add primary key
  434. if (paging2.OrderByList.Count == 0)
  435. {
  436. paging2.OrderByList.Add(new SimplePagingFieldItem(Simple.FieldNameConstants.SimpleId));
  437. }
  438. //Determine the paging sort
  439. var isPrimary = false;
  440. var orderByClause = string.Empty;
  441. foreach (var fieldItem in paging2.OrderByList)
  442. {
  443. if (!string.IsNullOrEmpty(orderByClause)) orderByClause += ", ";
  444. switch (fieldItem.Field.ToString().ToLower())
  445. {
  446. case "myreadonly": orderByClause += "[" + (from x in fieldList where x.Alias.ToLower() == fieldItem.Field.ToString().ToLower() select x).FirstOrDefault().Table + "].[my_readonly]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  447. case "name": orderByClause += "[" + (from x in fieldList where x.Alias.ToLower() == fieldItem.Field.ToString().ToLower() select x).FirstOrDefault().Table + "].[name]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  448. case "newint": orderByClause += "[" + (from x in fieldList where x.Alias.ToLower() == fieldItem.Field.ToString().ToLower() select x).FirstOrDefault().Table + "].[new_int]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  449. case "simpleid": orderByClause += "[" + (from x in fieldList where x.Alias.ToLower() == fieldItem.Field.ToString().ToLower() select x).FirstOrDefault().Table + "].[simple_id]" + (fieldItem.Ascending ? string.Empty : " DESC"); isPrimary = true;break;
  450. case "createddate": orderByClause += "[t0].[created_date]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  451. case "createdby": orderByClause += "[t0].[created_by]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  452. case "modifieddate": orderByClause += "[t0].[modified_date]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  453. case "modifiedby": orderByClause += "[t0].[modified_by]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  454. case "timestamp": orderByClause += "[t0].[time_stamp]" + (fieldItem.Ascending ? string.Empty : " DESC"); break;
  455. default: throw new Exception("The order by clause is not valid.");
  456. }
  457. }
  458. //Get the primary key for predictable sorts
  459. string primarySortKey = string.Empty;
  460. primarySortKey = "[t0].[simple_id]";
  461. sb.AppendLine(", ROW_NUMBER() OVER (ORDER BY " + orderByClause + ((primarySortKey == string.Empty) || ((isPrimary && (!string.IsNullOrEmpty(primarySortKey)))) ? string.Empty : ", " + primarySortKey) + ") AS Row");
  462. //Calculate the FROM clause
  463. index = 0;
  464. sb.Append("FROM ");
  465. foreach (LinqSQLFromClause fromClause in fromLinkList)
  466. {
  467. sb.Append("[" + fromClause.Schema + "].[" + fromClause.TableName + "] AS [" + fromClause.Alias + "] ");
  468. if (optimizer.NoLocking) sb.Append("WITH (NOLOCK)");
  469. if (!string.IsNullOrEmpty(fromClause.LinkClause)) sb.Append(fromClause.LinkClause + " ");
  470. if (index < fromLinkList.Count - 1)
  471. {
  472. sb.AppendLine();
  473. sb.Append("LEFT OUTER JOIN ");
  474. }
  475. index++;
  476. }
  477. sb.AppendLine();
  478. //Calculate the WHERE clause
  479. if (!string.IsNullOrEmpty(whereClause))
  480. {
  481. foreach (LinqSQLFromClause fromClause in fromLinkList)
  482. {
  483. //Only process table that were original and not inserted above
  484. if (fromClause.AnchorAlias == string.Empty)
  485. {
  486. whereClause = LinqSQLParser.GetRemappedLinqSql(fromClause, whereClause, fromLinkList, LinqSQLParser.ObjectTypeConstants.Table);
  487. }
  488. }
  489. sb.Append("WHERE " + whereClause);
  490. }
  491. sb.AppendLine(") AS [t0]");
  492. sb.AppendLine("WHERE (Row >= " + (((paging2.PageIndex - 1) * paging2.RecordsperPage) + 1) + ") AND (Row <= " + (paging2.PageIndex * paging2.RecordsperPage) + ")");
  493. return sb.ToString();
  494. }
  495. #endregion
  496. /// <summary>
  497. /// Persists this collection to store.
  498. /// </summary>
  499. public override void Persist()
  500. {
  501. try
  502. {
  503. foreach (Simple item in this)
  504. {
  505. if (item.wrappedClass.RowState != DataRowState.Unchanged)
  506. item.OnValidate(new BusinessObjectEventArgs(item));
  507. }
  508. lock (wrappedClass.SubDomain)
  509. {
  510. wrappedClass.Persist();
  511. }
  512. }
  513. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  514. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  515. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  516. }
  517. /// <summary>
  518. /// Select all objects from store.
  519. /// </summary>
  520. public static SimpleCollection RunSelect()
  521. {
  522. return RunSelect(ConfigurationValues.GetInstance().Modifier);
  523. }
  524. /// <summary>
  525. /// Select all objects from store.
  526. /// </summary>
  527. public static SimpleCollection RunSelect(string modifier)
  528. {
  529. try
  530. {
  531. var returnVal = new SimpleCollection(DomainSimpleCollection.RunSelect(modifier));
  532. return returnVal;
  533. }
  534. catch (System.Data.DBConcurrencyException dbcex) { throw new Widgetsphere.Core.Exceptions.ConcurrencyException(GlobalValues.ERROR_CONCURRENCY_FAILURE, dbcex); }
  535. catch (System.Data.SqlClient.SqlException sqlexp) { if (sqlexp.Number == 547 || sqlexp.Number == 2627) throw new Widgetsphere.Core.Exceptions.UniqueConstraintViolatedException(GlobalValues.ERROR_CONSTRAINT_FAILURE, sqlexp); else throw; }
  536. catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); throw; }
  537. }
  538. /// <summary>
  539. /// Using the specified Where expression, execute a query against the database to return a result set
  540. /// </summary>
  541. /// <param name="where">The expression that determines the records selected</param>
  542. public static SimpleCollection RunSelect(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  543. {
  544. return RunSelect(where, ConfigurationValues.GetInstance().Modifier);
  545. }
  546. /// <summary>
  547. /// Using the specified Where expression, execute a query against the database to return a result set
  548. /// </summary>
  549. /// <param name="where">The expression that determines the records selected</param>
  550. /// <param name="modifier">The modified audit trail</param>
  551. public static SimpleCollection RunSelect(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, string modifier)
  552. {
  553. return RunSelect(where, new QueryOptimizer(), modifier);
  554. }
  555. /// <summary>
  556. /// Using the specified Where expression, execute a query against the database to return a result set
  557. /// </summary>
  558. /// <param name="where">The expression that determines the records selected</param>
  559. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  560. /// <param name="modifier">The modified audit trail</param>
  561. public static SimpleCollection RunSelect(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer, string modifier)
  562. {
  563. var subDomain = new SubDomain(modifier);
  564. var dc = new DataContext(ConfigurationValues.GetInstance().ConnectionString);
  565. var template = dc.GetTable<SimpleQuery>();
  566. var cmd = BusinessCollectionPersistableBase.GetCommand<SimpleQuery>(dc, template, where);
  567. cmd.CommandTimeout = ConfigurationValues.GetInstance().DefaultTimeOut;
  568. var parser = LinqSQLParser.Create(cmd.CommandText, LinqSQLParser.ObjectTypeConstants.Table);
  569. cmd.CommandText = parser.GetSQL(optimizer);
  570. dc.Connection.Open();
  571. var startTime = DateTime.Now;
  572. var result = dc.Translate<SimpleQuery>(cmd.ExecuteReader());
  573. var endTime = DateTime.Now;
  574. optimizer.TotalMilliseconds = (long)endTime.Subtract(startTime).TotalMilliseconds;
  575. var retval = subDomain.GetCollection<SimpleCollection>();
  576. var pkList = new HashSet<string>();
  577. foreach (var item in result)
  578. {
  579. var pk = item.SinglePrimaryKeyValue();
  580. if (!pkList.Contains(pk))
  581. {
  582. pkList.Add(pk);
  583. var newItem = retval.NewItem(item.SimpleId);
  584. LoadDataRow(item, newItem);
  585. retval.AddItem(newItem);
  586. }
  587. }
  588. retval.wrappedClass.AcceptChanges();
  589. retval.wrappedClass.EndLoadData();
  590. dc.Connection.Close();
  591. return retval;
  592. }
  593. /// <summary>
  594. /// Using the specified Where expression, execute a query against the database to return a result set
  595. /// </summary>
  596. /// <param name="where">The expression that determines the records selected</param>
  597. /// <param name="paging">The paging object to determine how the results are paged.</param>
  598. public static SimpleCollection RunSelect(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Acme.TestModel.Business.Objects.SimplePaging paging)
  599. {
  600. return RunSelect(where, paging, ConfigurationValues.GetInstance().Modifier);
  601. }
  602. /// <summary>
  603. /// Using the specified Where expression, execute a query against the database to return a result set
  604. /// </summary>
  605. /// <param name="where">The expression that determines the records selected</param>
  606. /// <param name="paging">The paging object to determine how the results are paged.</param>
  607. /// <param name="modifier">The modified audit trail</param>
  608. public static SimpleCollection RunSelect(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Acme.TestModel.Business.Objects.SimplePaging paging, string modifier)
  609. {
  610. return RunSelect(where, paging, new QueryOptimizer(), modifier);
  611. }
  612. /// <summary>
  613. /// Using the specified Where expression, execute a query against the database to return a result set
  614. /// </summary>
  615. /// <param name="where">The expression that determines the records selected</param>
  616. /// <param name="paging">The paging object to determine how the results are paged.</param>
  617. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  618. /// <param name="modifier">The modified audit trail</param>
  619. public static SimpleCollection RunSelect(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Acme.TestModel.Business.Objects.SimplePaging paging, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer, string modifier)
  620. {
  621. if (paging == null) throw new Exception("The paging object cannot be null.");
  622. var subDomain = new SubDomain(modifier);
  623. var dc = new DataContext(ConfigurationValues.GetInstance().ConnectionString);
  624. var template = dc.GetTable<SimpleQuery>();
  625. var cmd = BusinessCollectionPersistableBase.GetCommand<SimpleQuery>(dc, template, where);
  626. cmd.CommandTimeout = ConfigurationValues.GetInstance().DefaultTimeOut;
  627. var parser = LinqSQLParser.Create(cmd.CommandText, paging, LinqSQLParser.ObjectTypeConstants.Table);
  628. cmd.CommandText = parser.GetSQL(optimizer);
  629. dc.Connection.Open();
  630. var startTime = DateTime.Now;
  631. var result = dc.Translate<SimpleQuery>(cmd.ExecuteReader());
  632. var endTime = DateTime.Now;
  633. optimizer.TotalMilliseconds = (long)endTime.Subtract(startTime).TotalMilliseconds;
  634. var retval = subDomain.GetCollection<SimpleCollection>();
  635. var pkList = new HashSet<string>();
  636. foreach (var item in result)
  637. {
  638. var pk = item.SinglePrimaryKeyValue();
  639. if (!pkList.Contains(pk))
  640. {
  641. pkList.Add(pk);
  642. var newItem = retval.NewItem(item.SimpleId);
  643. LoadDataRow(item, newItem);
  644. retval.AddItem(newItem);
  645. }
  646. }
  647. retval.wrappedClass.AcceptChanges();
  648. retval.wrappedClass.EndLoadData();
  649. dc.Connection.Close();
  650. paging.RecordCount = GetCount(where);
  651. return retval;
  652. }
  653. private static void LoadDataRow(SimpleQuery item, Simple newItem)
  654. {
  655. newItem.wrappedClass["simple_id"] = item.SimpleId;
  656. newItem.wrappedClass["new_int"] = item.NewInt;
  657. newItem.wrappedClass["my_readonly"] = item.MyReadonly;
  658. newItem.wrappedClass["name"] = StringHelper.ConvertToDatabase(item.Name);
  659. newItem.wrappedClass["CreatedDate"] = StringHelper.ConvertToDatabase(item.CreatedDate);
  660. newItem.wrappedClass["CreatedBy"] = StringHelper.ConvertToDatabase(item.CreatedBy);
  661. newItem.wrappedClass["ModifiedDate"] = StringHelper.ConvertToDatabase(item.ModifiedDate);
  662. newItem.wrappedClass["ModifiedBy"] = StringHelper.ConvertToDatabase(item.ModifiedBy);
  663. newItem.wrappedClass["TimeStamp"] = item.TimeStamp;
  664. }
  665. /// <summary>
  666. /// Get the maximum value of the field for all objects
  667. /// </summary>
  668. /// <param name="select">The field to aggregate</param>
  669. public static int? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int>> select)
  670. {
  671. return GetMax(select, x => true);
  672. }
  673. /// <summary>
  674. /// Get the maximum value of the field in the set of records that match the Where condition
  675. /// </summary>
  676. /// <param name="select">The field to aggregate</param>
  677. /// <param name="where">The expression that determines the records selected</param>
  678. public static int? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  679. {
  680. return GetMax(select, where, new QueryOptimizer());
  681. }
  682. /// <summary>
  683. /// Get the maximum value of the field in the set of records that match the Where condition
  684. /// </summary>
  685. /// <param name="select">The field to aggregate</param>
  686. /// <param name="where">The expression that determines the records selected</param>
  687. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  688. public static int? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  689. {
  690. return BusinessObjectQuery<Simple, SimpleQuery, int>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  691. }
  692. /// <summary>
  693. /// Get the maximum value of the field for all objects
  694. /// </summary>
  695. /// <param name="select">The field to aggregate</param>
  696. public static int? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int?>> select)
  697. {
  698. return GetMax(select, x => true);
  699. }
  700. /// <summary>
  701. /// Get the maximum value of the field in the set of records that match the Where condition
  702. /// </summary>
  703. /// <param name="select">The field to aggregate</param>
  704. /// <param name="where">The expression that determines the records selected</param>
  705. public static int? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  706. {
  707. return GetMax(select, where, new QueryOptimizer());
  708. }
  709. /// <summary>
  710. /// Get the maximum value of the field in the set of records that match the Where condition
  711. /// </summary>
  712. /// <param name="select">The field to aggregate</param>
  713. /// <param name="where">The expression that determines the records selected</param>
  714. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  715. public static int? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  716. {
  717. return BusinessObjectQuery<Simple, SimpleQuery, int?>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  718. }
  719. /// <summary>
  720. /// Get the maximum value of the field for all objects
  721. /// </summary>
  722. /// <param name="select">The field to aggregate</param>
  723. public static Single? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, Single>> select)
  724. {
  725. return GetMax(select, x => true);
  726. }
  727. /// <summary>
  728. /// Get the maximum value of the field in the set of records that match the Where condition
  729. /// </summary>
  730. /// <param name="select">The field to aggregate</param>
  731. /// <param name="where">The expression that determines the records selected</param>
  732. public static Single? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, Single>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  733. {
  734. return GetMax(select, where, new QueryOptimizer());
  735. }
  736. /// <summary>
  737. /// Get the maximum value of the field in the set of records that match the Where condition
  738. /// </summary>
  739. /// <param name="select">The field to aggregate</param>
  740. /// <param name="where">The expression that determines the records selected</param>
  741. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  742. public static Single? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, Single>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  743. {
  744. return BusinessObjectQuery<Simple, SimpleQuery, Single>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  745. }
  746. /// <summary>
  747. /// Get the maximum value of the field for all objects
  748. /// </summary>
  749. /// <param name="select">The field to aggregate</param>
  750. public static Single? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, Single?>> select)
  751. {
  752. return GetMax(select, x => true);
  753. }
  754. /// <summary>
  755. /// Get the maximum value of the field in the set of records that match the Where condition
  756. /// </summary>
  757. /// <param name="select">The field to aggregate</param>
  758. /// <param name="where">The expression that determines the records selected</param>
  759. public static Single? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, Single?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  760. {
  761. return GetMax(select, where, new QueryOptimizer());
  762. }
  763. /// <summary>
  764. /// Get the maximum value of the field in the set of records that match the Where condition
  765. /// </summary>
  766. /// <param name="select">The field to aggregate</param>
  767. /// <param name="where">The expression that determines the records selected</param>
  768. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  769. public static Single? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, Single?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  770. {
  771. return BusinessObjectQuery<Simple, SimpleQuery, Single?>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  772. }
  773. /// <summary>
  774. /// Get the maximum value of the field for all objects
  775. /// </summary>
  776. /// <param name="select">The field to aggregate</param>
  777. public static double? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, double>> select)
  778. {
  779. return GetMax(select, x => true);
  780. }
  781. /// <summary>
  782. /// Get the maximum value of the field in the set of records that match the Where condition
  783. /// </summary>
  784. /// <param name="select">The field to aggregate</param>
  785. /// <param name="where">The expression that determines the records selected</param>
  786. public static double? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, double>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  787. {
  788. return GetMax(select, where, new QueryOptimizer());
  789. }
  790. /// <summary>
  791. /// Get the maximum value of the field in the set of records that match the Where condition
  792. /// </summary>
  793. /// <param name="select">The field to aggregate</param>
  794. /// <param name="where">The expression that determines the records selected</param>
  795. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  796. public static double? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, double>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  797. {
  798. return BusinessObjectQuery<Simple, SimpleQuery, double>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  799. }
  800. /// <summary>
  801. /// Get the maximum value of the field for all objects
  802. /// </summary>
  803. /// <param name="select">The field to aggregate</param>
  804. public static double? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, double?>> select)
  805. {
  806. return GetMax(select, x => true);
  807. }
  808. /// <summary>
  809. /// Get the maximum value of the field in the set of records that match the Where condition
  810. /// </summary>
  811. /// <param name="select">The field to aggregate</param>
  812. /// <param name="where">The expression that determines the records selected</param>
  813. public static double? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, double?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  814. {
  815. return GetMax(select, where, new QueryOptimizer());
  816. }
  817. /// <summary>
  818. /// Get the maximum value of the field in the set of records that match the Where condition
  819. /// </summary>
  820. /// <param name="select">The field to aggregate</param>
  821. /// <param name="where">The expression that determines the records selected</param>
  822. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  823. public static double? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, double?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  824. {
  825. return BusinessObjectQuery<Simple, SimpleQuery, double?>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  826. }
  827. /// <summary>
  828. /// Get the maximum value of the field for all objects
  829. /// </summary>
  830. /// <param name="select">The field to aggregate</param>
  831. public static decimal? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, decimal>> select)
  832. {
  833. return GetMax(select, x => true);
  834. }
  835. /// <summary>
  836. /// Get the maximum value of the field in the set of records that match the Where condition
  837. /// </summary>
  838. /// <param name="select">The field to aggregate</param>
  839. /// <param name="where">The expression that determines the records selected</param>
  840. public static decimal? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, decimal>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  841. {
  842. return GetMax(select, where, new QueryOptimizer());
  843. }
  844. /// <summary>
  845. /// Get the maximum value of the field in the set of records that match the Where condition
  846. /// </summary>
  847. /// <param name="select">The field to aggregate</param>
  848. /// <param name="where">The expression that determines the records selected</param>
  849. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  850. public static decimal? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, decimal>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  851. {
  852. return BusinessObjectQuery<Simple, SimpleQuery, decimal>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  853. }
  854. /// <summary>
  855. /// Get the maximum value of the field for all objects
  856. /// </summary>
  857. /// <param name="select">The field to aggregate</param>
  858. public static decimal? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, decimal?>> select)
  859. {
  860. return GetMax(select, x => true);
  861. }
  862. /// <summary>
  863. /// Get the maximum value of the field in the set of records that match the Where condition
  864. /// </summary>
  865. /// <param name="select">The field to aggregate</param>
  866. /// <param name="where">The expression that determines the records selected</param>
  867. public static decimal? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, decimal?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  868. {
  869. return GetMax(select, where, new QueryOptimizer());
  870. }
  871. /// <summary>
  872. /// Get the maximum value of the field in the set of records that match the Where condition
  873. /// </summary>
  874. /// <param name="select">The field to aggregate</param>
  875. /// <param name="where">The expression that determines the records selected</param>
  876. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  877. public static decimal? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, decimal?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  878. {
  879. return BusinessObjectQuery<Simple, SimpleQuery, decimal?>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  880. }
  881. /// <summary>
  882. /// Get the maximum value of the field for all objects
  883. /// </summary>
  884. /// <param name="select">The field to aggregate</param>
  885. public static string GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, string>> select)
  886. {
  887. return GetMax(select, x => true);
  888. }
  889. /// <summary>
  890. /// Get the maximum value of the field in the set of records that match the Where condition
  891. /// </summary>
  892. /// <param name="select">The field to aggregate</param>
  893. /// <param name="where">The expression that determines the records selected</param>
  894. public static string GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, string>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  895. {
  896. return GetMax(select, where, new QueryOptimizer());
  897. }
  898. /// <summary>
  899. /// Get the maximum value of the field in the set of records that match the Where condition
  900. /// </summary>
  901. /// <param name="select">The field to aggregate</param>
  902. /// <param name="where">The expression that determines the records selected</param>
  903. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  904. public static string GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, string>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  905. {
  906. return BusinessObjectQuery<Simple, SimpleQuery, string>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  907. }
  908. /// <summary>
  909. /// Get the maximum value of the field for all objects
  910. /// </summary>
  911. /// <param name="select">The field to aggregate</param>
  912. public static DateTime? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, DateTime>> select)
  913. {
  914. return GetMax(select, x => true);
  915. }
  916. /// <summary>
  917. /// Get the maximum value of the field in the set of records that match the Where condition
  918. /// </summary>
  919. /// <param name="select">The field to aggregate</param>
  920. /// <param name="where">The expression that determines the records selected</param>
  921. public static DateTime? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, DateTime>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  922. {
  923. return GetMax(select, where, new QueryOptimizer());
  924. }
  925. /// <summary>
  926. /// Get the maximum value of the field in the set of records that match the Where condition
  927. /// </summary>
  928. /// <param name="select">The field to aggregate</param>
  929. /// <param name="where">The expression that determines the records selected</param>
  930. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  931. public static DateTime? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, DateTime>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  932. {
  933. return BusinessObjectQuery<Simple, SimpleQuery, DateTime>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  934. }
  935. /// <summary>
  936. /// Get the maximum value of the field for all objects
  937. /// </summary>
  938. /// <param name="select">The field to aggregate</param>
  939. public static DateTime? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, DateTime?>> select)
  940. {
  941. return GetMax(select, x => true);
  942. }
  943. /// <summary>
  944. /// Get the maximum value of the field in the set of records that match the Where condition
  945. /// </summary>
  946. /// <param name="select">The field to aggregate</param>
  947. /// <param name="where">The expression that determines the records selected</param>
  948. public static DateTime? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, DateTime?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  949. {
  950. return GetMax(select, where, new QueryOptimizer());
  951. }
  952. /// <summary>
  953. /// Get the maximum value of the field in the set of records that match the Where condition
  954. /// </summary>
  955. /// <param name="select">The field to aggregate</param>
  956. /// <param name="where">The expression that determines the records selected</param>
  957. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  958. public static DateTime? GetMax(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, DateTime?>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  959. {
  960. return BusinessObjectQuery<Simple, SimpleQuery, DateTime?>.GetMax(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  961. }
  962. /// <summary>
  963. /// Get the minimum value of the field for all objects
  964. /// </summary>
  965. /// <param name="select">The field to aggregate</param>
  966. public static int? GetMin(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int>> select)
  967. {
  968. return GetMin(select, x => true);
  969. }
  970. /// <summary>
  971. /// Get the minimum value of the field in the set of records that match the Where condition
  972. /// </summary>
  973. /// <param name="select">The field to aggregate</param>
  974. /// <param name="where">The expression that determines the records selected</param>
  975. public static int? GetMin(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where)
  976. {
  977. return GetMin(select, where, new QueryOptimizer());
  978. }
  979. /// <summary>
  980. /// Get the minimum value of the field in the set of records that match the Where condition
  981. /// </summary>
  982. /// <param name="select">The field to aggregate</param>
  983. /// <param name="where">The expression that determines the records selected</param>
  984. /// <param name="optimizer">An object to specify querying parameters and return profiling information</param>
  985. public static int? GetMin(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int>> select, Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, bool>> where, Widgetsphere.Core.DataAccess.QueryOptimizer optimizer)
  986. {
  987. return BusinessObjectQuery<Simple, SimpleQuery, int>.GetMin(select, where, optimizer, "SIMPLE", GetDatabaseFieldName, LinqSQLParser.ObjectTypeConstants.Table);
  988. }
  989. /// <summary>
  990. /// Get the minimum value of the field for all objects
  991. /// </summary>
  992. /// <param name="select">The field to aggregate</param>
  993. public static int? GetMin(Expression<Func<Acme.TestModel.Business.LINQ.SimpleQuery, int?>> select)
  994. {
  995. return GetMin(select, x => true);
  996. }
  997. /// <summary>
  998. /// Get the minimum val…

Large files files are truncated, but you can click here to view the full file