Ejemplo n.º 1
0
        public void CallingAMethod()
        {
            StopWatchUtil.Time(
                () =>
            {
                // #example: Calling a method
                var result = from Item i in container
                             where i.ComplexMethod()
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 2
0
        public void SearchByGenericField()
        {
            StopWatchUtil.Time(
                () =>
            {
                Item item = LoadItemFromDatabase();

                var result = from GenericHolder <Item> h in container
                             where h.IndexedReference == item
                             select h;

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 3
0
        public void EndsWith()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));
                var query    = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexedString")
                .Constrain(criteria).EndsWith(true);

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 4
0
        public void SortingByIndexedField()
        {
            StopWatchUtil.Time(
                () =>
            {
                // #example: Sorting a huge result set
                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexedString").OrderAscending();
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 5
0
        public void Evalutions()
        {
            StopWatchUtil.Time(
                () =>
            {
                // #example: Evaluations
                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexedString").Constrain(new OnlyAbcItemsEvaluation());
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 6
0
        public void NotEquals()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Not equals
                var result = from Item i in container
                             where i.IndexedString != criteria
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            });
        }
Ejemplo n.º 7
0
        public void QueryForItemInCollection()
        {
            StopWatchUtil.Time(
                () =>
            {
                Item itemToQueryFor = LoadItemFromDatabase();

                // #example: Contains on collection
                var result = from CollectionHolder h in container
                             where h.Items.Contains(itemToQueryFor)
                             select h;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 8
0
        public void AdvancedLinqQueries()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Nagivating into collection
                var result = from CollectionHolder h in container
                             where h.Items.Any(i => i.IndexedString == criteria)
                             select h;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 9
0
        public void PropertiesWithSideEffects()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Complex property
                var result = from Item i in container
                             where i.PropertyWhichFiresEvent == criteria
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 10
0
        public void NotBiggerThan()
        {
            StopWatchUtil.Time(
                () =>
            {
                int criteria = rnd.Next(NumberOfItems);

                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexNumber")
                .Constrain(criteria).Not().Greater();

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 11
0
        public void SearchByGenericField()
        {
            StopWatchUtil.Time(
                () =>
            {
                Item item = LoadItemFromDatabase();

                var query = container.Query();
                query.Constrain(typeof(GenericHolder <Item>));
                query.Descend("indexedReference")
                .Constrain(item);

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 12
0
        public void NewerData()
        {
            StopWatchUtil.Time(
                () =>
            {
                var date = new DateTime(rnd.Next(NumberOfItems));

                // #example: Find a newer date
                var result = from Item i in container
                             where i.IndexDate > date
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 13
0
        public void FindADate()
        {
            StopWatchUtil.Time(
                () =>
            {
                var date = new DateTime(rnd.Next(NumberOfItems));

                // #example: Date comparisons are also fast
                var result = from Item i in container
                             where i.IndexDate == date
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 14
0
        public void BiggerThan()
        {
            StopWatchUtil.Time(
                () =>
            {
                int criteria = rnd.Next(NumberOfItems);

                // #example: Bigger than
                var result = from Item i in container
                             where i.IndexNumber > criteria
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 15
0
        public void EqualsOnIndexedField()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Equals on indexed field
                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexedString")
                .Constrain(criteria);
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            });
        }
Ejemplo n.º 16
0
        public void EqualsAcrossIndexedFields()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Equals across indexed fields
                // Note that the type of the 'indexedReference' has to the specific type
                // which holds the 'indexedString'
                var result = from ItemHolder h in container
                             where h.IndexedReference.IndexedString == criteria
                             select h;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 17
0
        public void QueryForItemInCollection()
        {
            StopWatchUtil.Time(
                () =>
            {
                Item itemToQueryFor = LoadItemFromDatabase();

                // #example: Contains on collection
                var query = container.Query();
                query.Constrain(typeof(CollectionHolder));
                query.Descend("items")
                .Constrain(itemToQueryFor);
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 18
0
        public void NewerData()
        {
            StopWatchUtil.Time(
                () =>
            {
                var date = new DateTime(rnd.Next(NumberOfItems));

                // #example: Find a newer date
                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexDate")
                .Constrain(date).Greater();
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 19
0
        public void FindADate()
        {
            StopWatchUtil.Time(
                () =>
            {
                var date = new DateTime(rnd.Next(NumberOfItems));

                // #example: Date comparisons are also fast
                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexDate")
                .Constrain(date);
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 20
0
        public void SearchByReference()
        {
            StopWatchUtil.Time(
                () =>
            {
                // #example: Query by reference
                Item item = LoadItemFromDatabase();

                var query = container.Query();
                query.Constrain(typeof(ItemHolder));
                query.Descend("indexedReference")
                .Constrain(item);
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 21
0
        public void InBetween()
        {
            StopWatchUtil.Time(
                () =>
            {
                int criteria        = rnd.Next(NumberOfItems);
                int biggerThanThis  = criteria - 10;
                int smallerThanThis = criteria + 10;

                // #example: In between
                var result = from Item i in container
                             where i.IndexNumber > biggerThanThis &&
                             i.IndexNumber < smallerThanThis
                             select i;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            });
        }
Ejemplo n.º 22
0
        public void SearchByReference()
        {
            StopWatchUtil.Time(
                () =>
            {
                // #example: Query by reference
                Item item = LoadItemFromDatabase();

                // #example: Query by reference
                // Note that the type of the 'indexedReference' has to the specific type
                // which holds the 'indexedString'
                var result = from ItemHolder h in container
                             where h.IndexedReference == item
                             select h;
                // #end example

                Console.WriteLine("Number of result items {0}", result.Count());
            }
                );
        }
Ejemplo n.º 23
0
        public void DescentIntoCollection()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Navigate into collection
                var query = container.Query();
                query.Constrain(typeof(CollectionHolder));
                query.Descend("items")
                .Descend("indexedString").Constrain(criteria);
                // #end example


                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 24
0
        public void EqualsAcrossIndexedFields()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Equals across indexed fields
                // Note that the type of the 'indexedReference' has to the specific type
                // which holds the 'indexedString'
                var query = container.Query();
                query.Constrain(typeof(ItemHolder));
                query.Descend("indexedReference").Descend("indexedString")
                .Constrain(criteria);
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }
Ejemplo n.º 25
0
        public void InBetween()
        {
            StopWatchUtil.Time(
                () =>
            {
                int criteria        = rnd.Next(NumberOfItems);
                int biggerThanThis  = criteria - 10;
                int smallerThanThis = criteria + 10;

                // #example: In between
                var query = container.Query();
                query.Constrain(typeof(Item));
                query.Descend("indexNumber")
                .Constrain(biggerThanThis).Greater().And(
                    query.Descend("indexNumber").Constrain(smallerThanThis).Smaller());
                // #end example

                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            });
        }
Ejemplo n.º 26
0
        public void EqualsAcrossObjectFields()
        {
            StopWatchUtil.Time(
                () =>
            {
                var criteria = Item.DataString(rnd.Next(NumberOfItems));

                // #example: Navigation across non concrete typed fields
                // The type of the 'indexedReference' is an object
                // Therefore the query engine cannot know the type and use that index
                var query = container.Query();
                query.Constrain(typeof(ObjectHolder));
                query.Descend("indexedReference").Descend("indexedString")
                .Constrain(criteria);
                // #end example


                var result = query.Execute();
                Console.WriteLine("Number of result items {0}", result.Count);
            }
                );
        }