public void PopulateCollectionAsync <T>(Criteria criteria, IOrderCriteria order = null, Action afterPopulation = null) where T : class, IBusinessObject, new()
 {
     if (this.OnAsyncOperationStarted != null)
     {
         this.OnAsyncOperationStarted(this, new EventArgs());
     }
     try
     {
         this.BusinessObjectCollection = Broker.GetBusinessObjectCollection <T>(criteria, order);
         if (afterPopulation != null)
         {
             afterPopulation();
         }
         if (this.OnAsyncOperationComplete != null)
         {
             this.OnAsyncOperationComplete(this, new EventArgs());
         }
     }
     catch (Exception ex)
     {
         if (this.OnAsyncOperationException != null)
         {
             this.OnAsyncOperationException(this, new ExceptionEventArgs(ex));
         }
     }
 }
Пример #2
0
        ///<summary>
        /// Based on the class definition and the orderByString an <see cref="OrderCriteria"/> object is created.
        /// The orderCriteria object is a set of order by fields including information on their
        /// business object properties and their dataSource.
        ///</summary>
        ///<param name="classDef">The class definition to use for building the order criteria</param>
        ///<param name="orderByString">The orderby string to use for creating the <see cref="OrderCriteria"/>.</param>
        ///<returns>the newly created <see cref="OrderCriteria"/> object.</returns>
        public static IOrderCriteria CreateOrderCriteria(IClassDef classDef, string orderByString)
        {
            if (classDef == null)
            {
                throw new ArgumentNullException("classDef");
            }
            IOrderCriteria orderCriteria = OrderCriteria.FromString(orderByString);

            try
            {
                //TODO Mark 20 Mar 2009: Souldn't the following code be stripped out into a PrepareOrderBy method that is called before loading? (Similar to PrepareCriteria)
                foreach (OrderCriteriaField field in orderCriteria.Fields)
                {
                    Source    source = field.Source;
                    IClassDef relatedClassDef;
                    IClassDef classDefOfField = classDef;
                    if (classDef.IsUsingClassTableInheritance())
                    {
                        classDefOfField = classDef.GetPropDef(field.PropertyName).ClassDef;
                    }
                    PrepareSource(classDefOfField, ref source, out relatedClassDef);
                    field.Source = source;

                    IPropDef propDef = relatedClassDef.GetPropDef(field.PropertyName);
                    field.FieldName = propDef.DatabaseFieldName;
                    field.Source.ChildSourceLeaf.EntityName = relatedClassDef.GetTableName(propDef);
                }
                return(orderCriteria);
            }
            catch (InvalidPropertyNameException)
            {
                throw new InvalidOrderCriteriaException("The orderByString '" + orderByString
                                                        + "' is not valid for the classDef '" + classDef.ClassNameFull);
            }
        }
        /// <summary>
        /// Load the Business Objects from the specific DataStore type that applies to this loader.
        /// In this case these objects are loaded from a <see cref="DataStoreInMemory"/>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="classDef"></param>
        /// <param name="selectQuery"></param>
        /// <returns></returns>
        protected override LoaderResult GetObjectsFromDataStore <T>(IClassDef classDef, ISelectQuery selectQuery)
        {
            Criteria       criteria      = selectQuery.Criteria;
            IOrderCriteria orderCriteria = selectQuery.OrderCriteria;

            IBusinessObjectCollection loadedBos = _dataStore.FindAll(classDef, criteria);

            loadedBos.Sort(orderCriteria);

            int totalNoOfRecords             = -1;
            int totalCountAvailableForPaging = totalNoOfRecords == -1 ? loadedBos.Count : totalNoOfRecords;

            ApplyLimitsToList(selectQuery, loadedBos);
            var loadedBoInfos = new List <LoadedBoInfo>();

            foreach (var loadedBo in loadedBos)
            {
                loadedBoInfos.Add(new LoadedBoInfo {
                    LoadedBo = (IBusinessObject)loadedBo
                });
            }
            return(new LoaderResult
            {
                LoadedBoInfos = loadedBoInfos,
                TotalCountAvailableForPaging = totalCountAvailableForPaging,
                LoadMechanismDescription = Convert.ToString(selectQuery.Criteria),
            });
        }
Пример #4
0
        public void PopulateCollectionAsync <T>(Criteria criteria, IOrderCriteria order = null, Action afterPopulation = null) where T : class, IBusinessObject, new()
        {
            if (GlobalUIRegistry.AsyncSettings.SynchroniseBackgroundOperations)
            {
                this.BusinessObjectCollection = Broker.GetBusinessObjectCollection <T>(criteria, order);
                afterPopulation();
                return;
            }
            var data = new ConcurrentDictionary <string, object>();

            data["businessobjectcollection"] = null;
            this.RunOnAsyncOperationStarted();
            (new HabaneroBackgroundWorker()).Run(this, data,
                                                 (d) =>
            {
                d["businessobjectcollection"] = Broker.GetBusinessObjectCollection <T>(criteria, order);
                return(true);
            },
                                                 (d) =>
            {
                this.PopulateCollectionFromAsyncUICallback(d, afterPopulation);
            },
                                                 null,
                                                 this.NotifyGridPopulationException);
        }
        public void PopulateCollectionAsync <T>(Criteria criteria, IOrderCriteria order, Action afterPopulation = null) where T : class, IBusinessObject, new()
        {
            if (GlobalUIRegistry.AsyncSettings.SynchroniseBackgroundOperations)
            {
                this.BusinessObjectCollection = Broker.GetBusinessObjectCollection <T>(criteria, order);
                if (afterPopulation != null)
                {
                    afterPopulation();
                }
                return;
            }
            lock (this)
            {
                if (this._inAsyncOperation)
                {
                    throw new MultipleAsyncOperationException("Application error: the application must not submit multiple asynchronous requests to a grid control");
                }
            }
            var data = new ConcurrentDictionary <string, object>();

            data["businessobjectcollection"] = null;
            this.RunOnAsyncOperationStarted();
            (new HabaneroBackgroundWorker()).Run(this, data,
                                                 (d) =>
            {
                d["businessobjectcollection"] = Broker.GetBusinessObjectCollection <T>(criteria, order);
                return(true);
            },
                                                 (d) =>
            {
                this.PopulateFromAsyncUICallback(d, afterPopulation);
            },
                                                 null,
                                                 this.NotifyGridPopulationException);
        }
Пример #6
0
 public void PopulateCollectionAsync <T>(Criteria criteria, IOrderCriteria order = null, Action afterPopulation = null) where T : class, IBusinessObject, new()
 {
     this.RunAsyncOperationStartedHandler();
     this.BusinessObjectCollection = Broker.GetBusinessObjectCollection <T>(criteria, order);
     this.RunAsyncOperationCompleteHandler();
     if (afterPopulation != null)
     {
         afterPopulation();
     }
 }
Пример #7
0
 public override void LoadWithLimit(Criteria searchCriteria, IOrderCriteria orderByClause,
                                    int firstRecordToLoad, int numberOfRecordsToLoad,
                                    out int totalNoOfRecords)
 {
     this.SelectQuery.Criteria          = searchCriteria;
     this.SelectQuery.OrderCriteria     = orderByClause;
     this.SelectQuery.FirstRecordToLoad = firstRecordToLoad;
     this.SelectQuery.Limit             = numberOfRecordsToLoad;
     Refresh();
     totalNoOfRecords = TotalCountAvailableForPaging;
 }
Пример #8
0
        public void TestFromString_BlankString()
        {
            //---------------Set up test pack-------------------
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = OrderCriteria.FromString(" ");

            //---------------Test Result -----------------------
            Assert.IsNotNull(orderCriteria);
            Assert.AreEqual(0, orderCriteria.Fields.Count);
            //---------------Tear Down -------------------------
        }
Пример #9
0
        public void TestFromString_SortOrder_IsCaseInsensitive()
        {
            //---------------Set up test pack-------------------

            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = OrderCriteria.FromString("TestProp dEsc, TestProp2 aSc");

            //---------------Test Result -----------------------
            Assert.AreEqual(2, orderCriteria.Fields.Count);
            Assert.AreEqual(SortDirection.Descending, orderCriteria.Fields[0].SortDirection);
            Assert.AreEqual(SortDirection.Ascending, orderCriteria.Fields[1].SortDirection);
            //---------------Tear Down -------------------------
        }
Пример #10
0
        public void TestFromString_Desc()
        {
            //---------------Set up test pack-------------------
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = OrderCriteria.FromString("TestProp DESC");

            //---------------Test Result -----------------------
            Assert.AreEqual(1, orderCriteria.Fields.Count);
            Assert.AreEqual("TestProp", orderCriteria.Fields[0].PropertyName);
            Assert.AreEqual(SortDirection.Descending, orderCriteria.Fields[0].SortDirection);
            //---------------Tear Down -------------------------
        }
Пример #11
0
        public void TestFromString()
        {
            //---------------Set up test pack-------------------
            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = OrderCriteria.FromString("TestProp");

            //---------------Test Result -----------------------
            Assert.AreEqual(1, orderCriteria.Fields.Count);
            IOrderCriteriaField orderCriteriaField = orderCriteria.Fields[0];

            Assert.AreEqual("TestProp", orderCriteriaField.PropertyName);
            Assert.IsNull(orderCriteriaField.Source);
            Assert.AreEqual(SortDirection.Ascending, orderCriteriaField.SortDirection);
            //---------------Tear Down -------------------------
        }
Пример #12
0
        public void TestCreateOrderCriteria()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDefWithDifferentTableAndFieldNames();
            IClassDef classdef = ClassDef.ClassDefs[typeof(MyBO)];
            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(classdef, "TestProp");
            //---------------Test Result -----------------------
            IOrderCriteriaField orderCriteriaField = orderCriteria.Fields[0];

            Assert.AreEqual(classdef.ClassName, orderCriteriaField.Source.Name);
            Assert.AreEqual(classdef.GetTableName(), orderCriteriaField.Source.EntityName);
            Assert.AreEqual(classdef.GetPropDef("TestProp").DatabaseFieldName, orderCriteriaField.FieldName);
            Assert.AreEqual(0, orderCriteriaField.Source.Joins.Count);
            //---------------Tear Down -------------------------
        }
Пример #13
0
        public void TestSetOrderCriteria_AddsJoinToSource_OnlyOnce()
        {
            //---------------Set up test pack-------------------
            MyRelatedBo.LoadClassDefWithDifferentTableAndFieldNames();
            IClassDef myBoClassdef = MyBO.LoadClassDefWithRelationship();

            ISelectQuery   selectQuery   = QueryBuilder.CreateSelectQuery(myBoClassdef);
            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(myBoClassdef, "MyRelationship.MyRelatedTestProp, MyRelationship.MyRelatedTestProp2");

            //---------------Execute Test ----------------------
            selectQuery.OrderCriteria = orderCriteria;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectQuery.Source.Joins.Count);
            //---------------Tear Down -------------------------
        }
Пример #14
0
        public void TestCreateOrderCriteria_ThroughRelationship_TwoLevels()
        {
            //---------------Set up test pack-------------------
            IClassDef    engineClassDef = Engine.LoadClassDef_IncludingCarAndOwner();
            const string orderByString  = "Car.Owner.Surname";

            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(engineClassDef, orderByString);
            //---------------Test Result -----------------------
            IOrderCriteriaField orderCriteriaField = orderCriteria.Fields[0];

            Assert.AreEqual("Surname", orderCriteriaField.PropertyName);
            Assert.AreEqual("Surname_field", orderCriteriaField.FieldName);
            Assert.AreEqual(1, orderCriteriaField.Source.Joins.Count);
            Assert.AreEqual("Engine.Car.Owner", orderCriteriaField.Source.ToString());
            //---------------Tear Down -------------------------
        }
        public void PopulateCollectionAsync <T>(Criteria criteria, IOrderCriteria order = null, Action afterPopulation = null) where T : class, IBusinessObject, new()
        {
            if (this.OnAsyncOperationStarted != null)
            {
                this.OnAsyncOperationStarted(this, new EventArgs());
            }
            var data = new ConcurrentDictionary <string, object>();

            data["collection"] = null;
            (new HabaneroBackgroundWorker()).Run(this, data,
                                                 (d) => { d["collection"] = Broker.GetBusinessObjectCollection <T>(criteria, order); return(true); },
                                                 (d) =>
            {
                this.PopulateCollectionUICallback(afterPopulation, d);
            },
                                                 null,
                                                 this.NotifyPopulationException);
            if (this.OnAsyncOperationComplete != null)
            {
                this.OnAsyncOperationComplete(this, new EventArgs());
            }
        }
Пример #16
0
        public void TestSetOrderCriteria_AddsJoinToSource_TwoLevels()
        {
            //---------------Set up test pack-------------------
            IClassDef engineClassDef = Engine.LoadClassDef_IncludingCarAndOwner();

            ISelectQuery   selectQuery   = QueryBuilder.CreateSelectQuery(engineClassDef);
            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(engineClassDef, "Car.Owner.Surname");

            //---------------Execute Test ----------------------
            selectQuery.OrderCriteria = orderCriteria;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectQuery.Source.Joins.Count);
            Source carSource = selectQuery.Source.Joins[0].ToSource;

            Assert.AreEqual("Car", carSource.Name);
            Assert.AreEqual(1, carSource.Joins.Count);
            Assert.AreEqual(carSource.ToString(), carSource.Joins[0].FromSource.ToString());
            Assert.AreEqual("Owner", carSource.Joins[0].ToSource.Name);

            //---------------Tear Down -------------------------
        }
Пример #17
0
        public void TestCompare_ThroughRelationship()
        {
            //---------------Set up test pack-------------------
            Car car1 = new Car();

            car1.CarRegNo = "2";
            Car car2 = new Car();

            car2.CarRegNo = "2";

            Engine engine1 = new Engine();

            engine1.CarID    = car1.CarID;
            engine1.EngineNo = "20";

            Engine engine2 = new Engine();

            engine2.CarID    = car2.CarID;
            engine2.EngineNo = "50";

            ITransactionCommitter committer = BORegistry.DataAccessor.CreateTransactionCommitter();

            committer.AddBusinessObject(car1);
            committer.AddBusinessObject(car2);
            committer.AddBusinessObject(engine1);
            committer.AddBusinessObject(engine2);
            committer.CommitTransaction();

            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(engine1.ClassDef, "Car.CarRegNo, EngineNo");

            //---------------Assert PreConditions---------------
            //---------------Execute Test ----------------------
            int comparisonResult = orderCriteria.Compare(engine1, engine2);

            //---------------Test Result -----------------------
            Assert.Less(comparisonResult, 0, "engine1 should be less as the car regnos are equal and its engine no is less");
            //---------------Tear Down -------------------------
        }
Пример #18
0
        public void TestCreateOrderCriteria_ThroughRelationship()
        {
            //---------------Set up test pack-------------------
            IClassDef myRelatedBoClassDef = MyRelatedBo.LoadClassDefWithDifferentTableAndFieldNames();
            IClassDef myBoClassdef        = MyBO.LoadClassDefWithRelationship();

            //---------------Execute Test ----------------------
            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(myBoClassdef, "MyRelationship.MyRelatedTestProp");
            //---------------Test Result -----------------------
            IOrderCriteriaField orderCriteriaField = orderCriteria.Fields[0];

            Assert.AreEqual(myRelatedBoClassDef.GetPropDef("MyRelatedTestProp").DatabaseFieldName, orderCriteriaField.FieldName);
            Assert.AreEqual(myBoClassdef.ClassName, orderCriteriaField.Source.Name);
            Assert.AreEqual(myBoClassdef.GetTableName(), orderCriteriaField.Source.EntityName);
            Assert.AreEqual(1, orderCriteriaField.Source.Joins.Count);
            Source.Join relJoin = orderCriteriaField.Source.Joins[0];
            Assert.AreEqual("MyRelationship", relJoin.ToSource.Name);
            Assert.AreEqual(myRelatedBoClassDef.GetTableName(), relJoin.ToSource.EntityName);
            Assert.AreEqual(1, relJoin.JoinFields.Count);
            Assert.AreEqual("RelatedID", relJoin.JoinFields[0].FromField.PropertyName);
            Assert.AreEqual("MyRelatedBoID", relJoin.JoinFields[0].ToField.PropertyName);
            //---------------Tear Down -------------------------
        }
Пример #19
0
        public void TestSetOrderCriteria_AddsJoinToSource()
        {
            //---------------Set up test pack-------------------
            MyRelatedBo.LoadClassDefWithDifferentTableAndFieldNames();
            IClassDef myBoClassdef = MyBO.LoadClassDefWithRelationship_DifferentTableAndFieldNames();

            ISelectQuery   selectQuery   = QueryBuilder.CreateSelectQuery(myBoClassdef);
            IOrderCriteria orderCriteria = QueryBuilder.CreateOrderCriteria(myBoClassdef, "MyRelationship.MyRelatedTestProp");

            //---------------Execute Test ----------------------
            selectQuery.OrderCriteria = orderCriteria;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectQuery.Source.Joins.Count);
            Source.Join join = selectQuery.Source.Joins[0];
            Assert.AreEqual(selectQuery.Source, join.FromSource);
            Assert.AreEqual("MyRelationship", join.ToSource.Name);
            Assert.AreEqual(1, join.JoinFields.Count);
            Assert.AreEqual("RelatedID", join.JoinFields[0].FromField.PropertyName);
            Assert.AreEqual("related_id", join.JoinFields[0].FromField.FieldName);
            Assert.AreEqual("MyRelatedBoID", join.JoinFields[0].ToField.PropertyName);
            Assert.AreEqual("My_Related_Bo_ID", join.JoinFields[0].ToField.FieldName);
            //---------------Tear Down -------------------------
        }
Пример #20
0
 /// <summary>
 /// Loads a BusinessObjectCollection using the criteria given, applying the order criteria to order the collection that is returned.
 /// </summary>
 /// <param name="classDef">The ClassDef for the collection to load</param>
 /// <param name="criteria">The criteria to use to load the business object collection</param>
 /// <returns>The loaded collection</returns>
 /// <param name="orderCriteria">The order criteria to use (ie what fields to order the collection on)</param>
 public IBusinessObjectCollection GetBusinessObjectCollection(IClassDef classDef, Criteria criteria, IOrderCriteria orderCriteria)
 {
     if (_businessObjectLoaders.ContainsKey(classDef.ClassType))
     {
         return(_businessObjectLoaders[classDef.ClassType].GetBusinessObjectCollection(classDef, criteria, orderCriteria));
     }
     return(_defaultBusinessObjectLoader.GetBusinessObjectCollection(classDef, criteria, orderCriteria));
 }
Пример #21
0
 /// <summary>
 /// Loads business objects that match the search criteria provided,
 /// loaded in the order specified, and limiting the number of objects loaded.
 /// The limited list of Ts specified as follows:
 /// If you want record 6 to 15 then
 /// <paramref name="firstRecordToLoad"/> will be set to 5 (this is zero based) and
 /// <paramref name="numberOfRecordsToLoad"/> will be set to 10.
 /// This will load 10 records, starting at record 6 of the ordered set (ordered by the <paramref name="orderCriteria"/>).
 /// If there are fewer than 15 records in total, then the remaining records after record 6 willbe returned.
 /// </summary>
 /// <remarks>
 /// As a design decision, we have elected for the <paramref name="firstRecordToLoad"/> to be zero based since this is consistent with the limit clause in used by MySql etc.
 /// Also, the <paramref name="numberOfRecordsToLoad"/> returns the specified number of records unless its value is '-1' where it will
 /// return all the remaining records from the specified <paramref name="firstRecordToLoad"/>.
 /// If you give '0' as the value for the <paramref name="numberOfRecordsToLoad"/> parameter, it will load zero records.
 /// </remarks>
 /// <example>
 /// The following code demonstrates how to loop through the invoices in the data store,
 /// ten at a time, and print their details:
 /// <code>
 /// BusinessObjectCollection&lt;Invoice&gt; col = new BusinessObjectCollection&lt;Invoice&gt;();
 /// int interval = 10;
 /// int firstRecord = 0;
 /// int totalNoOfRecords = firstRecord + 1;
 /// while (firstRecord &lt; totalNoOfRecords)
 /// {
 ///     col.LoadWithLimit("", "InvoiceNo", firstRecord, interval, out totalNoOfRecords);
 ///     Debug.Print("The next {0} invoices:", interval);
 ///     col.ForEach(bo =&gt; Debug.Print(bo.ToString()));
 ///     firstRecord += interval;
 /// }</code>
 /// </example>
 /// <param name="criteria">The search criteria</param>
 /// <param name="orderCriteria">The order-by clause</param>
 /// <param name="firstRecordToLoad">The first record to load (NNB: this is zero based)</param>
 /// <param name="numberOfRecordsToLoad">The number of records to be loaded</param>
 /// <param name="totalNoOfRecords">The total number of records matching the criteria</param>
 /// <returns>The loaded collection, limited in the specified way.</returns>
 public BusinessObjectCollection <T> GetBusinessObjectCollection <T>(Criteria criteria, IOrderCriteria orderCriteria, int firstRecordToLoad, int numberOfRecordsToLoad, out int totalNoOfRecords) where T : class, IBusinessObject, new()
 {
     if (_businessObjectLoaders.ContainsKey(typeof(T)))
     {
         return(_businessObjectLoaders[typeof(T)].GetBusinessObjectCollection <T>(criteria, orderCriteria, firstRecordToLoad, numberOfRecordsToLoad, out totalNoOfRecords));
     }
     return(_defaultBusinessObjectLoader.GetBusinessObjectCollection <T>(criteria, orderCriteria, firstRecordToLoad, numberOfRecordsToLoad, out totalNoOfRecords));
 }
Пример #22
0
 public void SetOrderBy(IOrderCriteria orderCriteria)
 {
     this.OrderCriteria = orderCriteria;
 }
Пример #23
0
 /// <summary>
 /// Loads the Business object collection with the appropriate items.
 /// See <see cref="IBusinessObjectLoader.GetBusinessObjectCollection{T}(Habanero.Base.Criteria,Habanero.Base.IOrderCriteria,int,int,out int)"/> for a full explanation.
 /// </summary>
 /// <param name="def"></param>
 /// <param name="criteria"></param>
 /// <param name="orderCriteria"></param>
 /// <param name="firstRecordToLoad"></param>
 /// <param name="numberOfRecordsToLoad"></param>
 /// <param name="records"></param>
 /// <returns></returns>
 public IBusinessObjectCollection GetBusinessObjectCollection(IClassDef def, Criteria criteria, IOrderCriteria orderCriteria, int firstRecordToLoad, int numberOfRecordsToLoad, out int records)
 {
     if (_businessObjectLoaders.ContainsKey(def.ClassType))
     {
         return(_businessObjectLoaders[def.ClassType].GetBusinessObjectCollection(def, criteria, orderCriteria, firstRecordToLoad, numberOfRecordsToLoad, out records));
     }
     return(_defaultBusinessObjectLoader.GetBusinessObjectCollection(def, criteria, orderCriteria, firstRecordToLoad, numberOfRecordsToLoad, out records));
 }
Пример #24
0
 /// <summary>
 /// Loads a BusinessObjectCollection using the criteria given, applying the order criteria to order the collection that is returned.
 /// </summary>
 /// <typeparam name="T">The type of collection to load. This must be a class that implements IBusinessObject and has a parameterless constructor</typeparam>
 /// <param name="criteria">The criteria to use to load the business object collection</param>
 /// <returns>The loaded collection</returns>
 /// <param name="orderCriteria">The order criteria to use (ie what fields to order the collection on)</param>
 public BusinessObjectCollection <T> GetBusinessObjectCollection <T>(Criteria criteria, IOrderCriteria orderCriteria) where T : class, IBusinessObject, new()
 {
     if (_businessObjectLoaders.ContainsKey(typeof(T)))
     {
         return(_businessObjectLoaders[typeof(T)].GetBusinessObjectCollection <T>(criteria, orderCriteria));
     }
     return(_defaultBusinessObjectLoader.GetBusinessObjectCollection <T>(criteria, orderCriteria));
 }
Пример #25
0
 /// <summary>
 /// Sorts a <see cref="IQueryResult"/> using an <see cref="IOrderCriteria"/>
 /// </summary>
 /// <param name="queryResult"></param>
 /// <param name="orderCriteria"></param>
 public void Sort(IQueryResult queryResult, IOrderCriteria orderCriteria)
 {
     queryResult.Rows.Sort(new RowComparer(orderCriteria, queryResult));
 }
Пример #26
0
 /// <summary>
 /// Loads a BusinessObjectCollection using the criteria given, applying the order criteria to order the collection that is returned.
 /// </summary>
 /// <typeparam name="T">The type of collection to load. This must be a class that implements IBusinessObject and has a parameterless constructor</typeparam>
 /// <param name="criteria">The criteria to use to load the business object collection</param>
 /// <returns>The loaded collection</returns>
 /// <param name="orderCriteria">The order criteria to use (ie what fields to order the collection on)</param>
 public static BusinessObjectCollection <T> GetBusinessObjectCollection <T>(Criteria criteria, IOrderCriteria orderCriteria)
     where T : class, IBusinessObject, new()
 {
     return(BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection <T>(criteria, orderCriteria));
 }
 public void SetOrderBy(IOrderCriteria orderCriteria)
 {
     this.OrderCriteria = orderCriteria;
 }
Пример #28
0
 public RowComparer(IOrderCriteria orderCriteria, IQueryResult queryResult)
 {
     _orderCriteria = orderCriteria;
     _queryResult   = queryResult;
 }