Beispiel #1
0
        public EntityType[] Filter(Rock.Orm.Common.WhereClip where, OrderByClip orderBy, int topCount, int skipCount)
        {
            if (filter == null)
            {
                lock (this)
                {
                    if (filter == null)
                    {
                        filter = new EntityArrayQuery <EntityType>(this.ToArray());
                    }
                }
            }

            return(filter.FindArray(where, orderBy, topCount, skipCount));
        }
Beispiel #2
0
        public void TestEntityArrayQuery()
        {
            Order[] orders = NBear.Data.Gateway.Default.FindArray <Order>();
            EntityArrayQuery <Order> query = new EntityArrayQuery <Order>(orders);

            Assert.AreEqual(orders.Length, query.FindArray().Length);
            Assert.IsNotNull(query.Find(WhereClip.All));
            Assert.AreEqual(orders.Length, query.FindArray(Order._.OrderID.Desc).Length);
            Assert.AreEqual(orders.Length, query.FindArray(Order._.OrderID > 0).Length);
            Assert.AreEqual(orders.Length, query.FindArray(Order._.OrderID > 0, Order._.OrderID.Desc).Length);
            Assert.IsNotNull(query.Find(10248));
            object avgResult = query.Avg(Order._.OrderID, Order._.OrderID > 0);

            Assert.IsTrue(((int)avgResult) > 0);
            object sumResult = query.Sum(Order._.OrderID, Order._.OrderID > 0);

            Assert.IsTrue((Convert.ToDouble(sumResult)) > 0);
            Assert.IsTrue((Convert.ToInt32(query.Count(Order._.OrderID, Order._.OrderID > 0, true))) > 0);

            Assert.IsTrue(query.FindArray(Order._.ShipCity.Like("%r%")).Length > 0);
        }