PageRenderTime 62ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

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

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

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