public void EagerLoadingTest()
        {
#if DEBUG
            EntityBase.LastSearches.Clear();
#endif

            SearchOptions so = new SearchOptions(typeof(Item));
            so.Conditions.Add("Name", "First category", "c");
            so.Conditions.Include("Category", "c");
            so.LoadAlso("PersonItemList");
            so.LoadAlso("Category");
            Item[] items = (Item[])so.Execute();
            if (items.Length == 0)
            {
                Assert.Inconclusive("No query results.");
            }

            foreach (Item item in items)
            {
                Category           cat  = item.Category;
                IList <PersonItem> list = item.PersonItemList;
            }
#if DEBUG
            Assert.AreEqual(1, EntityBase.LastSearches.Count, "Tenor has generated more than one query.");
#else
            Assert.Inconclusive("Can only check generated queries on debug mode.");
#endif
        }
        public void LinqSelectToLower()
        {
            string filterQuery = "j";

            //testing using linq lambda.
            IQueryable <Person> so = Tenor.Linq.SearchOptions <Person> .CreateQuery();

            so = so.Where(p => p.Active && p.Email.ToLower() == filterQuery);
            //so = so.Where(p => p.DepartmentList.Any(e => e.Name == "blah"));
            //so = so.Where(p => p.DepartmentList.Any(e => e.Name == "bleh"));
            so = so.OrderBy(p => p.Name);
            so = so.OrderByDescending(p => p.Active);
            so = so.Distinct();
            //so = so.Take(10);
            so = so.LoadAlso(p => p.DepartmentList);

            Person[] persons = so.ToArray();



            //testing using classic way.
            SearchOptions search = new SearchOptions(typeof(Person));

            search.Conditions.Add(Person.Properties.Active, true);
            search.Conditions.And(Person.Properties.Email, filterQuery, CompareOperator.EqualLower);
            search.Sorting.Add(Person.Properties.Name);
            search.Sorting.Add(Person.Properties.Active, SortOrder.Descending);
            search.Distinct = true;
            search.LoadAlso("DepartmentList");

            Person[] persons4 = (Person[])search.Execute();

            CollectionAssert.AreEqual(persons4, persons);
        }
        public void LinqSelectStartsWith()
        {
            string filterQuery = "j";

            //testing using linq lambda.
            IQueryable <Person> so = Tenor.Linq.SearchOptions <Person> .CreateQuery();

            so = so.Where(p => p.Active && p.Email.StartsWith(filterQuery));
            //so = so.Where(p => p.DepartmentList.Any(e => e.Name == "blah"));
            //so = so.Where(p => p.DepartmentList.Any(e => e.Name == "bleh"));
            so = so.OrderBy(p => p.Name);
            so = so.OrderByDescending(p => p.Active);
            so = so.Distinct();
            //so = so.Take(10);
            so = so.LoadAlso(p => p.DepartmentList);

            Person[] persons = so.ToArray();

            //testing using linq query
            var query =
                (
                    from person in Tenor.Linq.SearchOptions <Person> .CreateQuery()
                    where person.Active && person.Email.StartsWith(GetFilterTest(0, filterQuery))
                    orderby person.Name, person.Active descending
                    select person
                )
                .Distinct()
                .LoadAlso(p => p.DepartmentList);

            Person[] persons2 = query.ToArray();

            var valueInAEntity = new
            {
                Value = GetFilterTest(0, filterQuery)
            };

            //testing using linq query
            var query2 =
                (
                    from person in Tenor.Linq.SearchOptions <Person> .CreateQuery()
                    where person.Active && person.Email.StartsWith(valueInAEntity.Value)
                    orderby person.Name, person.Active descending
                    select person
                )
                .Distinct()
                .LoadAlso(p => p.DepartmentList);

            Person[] persons3 = query2.ToArray();


            //testing using classic way.
            SearchOptions search = new SearchOptions(typeof(Person));

            search.Conditions.Add(Person.Properties.Active, true);
            search.Conditions.And(Person.Properties.Email, filterQuery + "%", CompareOperator.Like);
            search.Sorting.Add(Person.Properties.Name);
            search.Sorting.Add(Person.Properties.Active, SortOrder.Descending);
            search.Distinct = true;
            search.LoadAlso("DepartmentList");

            Person[] persons4 = (Person[])search.Execute();

            CollectionAssert.AreEqual(persons2, persons);
            CollectionAssert.AreEqual(persons3, persons);
            CollectionAssert.AreEqual(persons4, persons);
        }