public IRavenQueryable <T> Query <T>(string indexName = null, string collectionName = null, bool isMapReduce = false)
        {
            var type = typeof(T);

            (indexName, collectionName) = ProcessQueryParameters(type, indexName, collectionName, Conventions);

            var queryStatistics = new QueryStatistics();
            var highlightings   = new LinqQueryHighlightings();

            var ravenQueryInspector = new RavenQueryInspector <T>();
            var ravenQueryProvider  = new RavenQueryProvider <T>(
                this,
                indexName,
                collectionName,
                type,
                queryStatistics,
                highlightings,
                isMapReduce,
                Conventions);

            ravenQueryInspector.Init(ravenQueryProvider,
                                     queryStatistics,
                                     highlightings,
                                     indexName,
                                     collectionName,
                                     null,
                                     this,
                                     isMapReduce);

            return(ravenQueryInspector);
        }
Exemplo n.º 2
0
 public void CanUnderstandAnd()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null,null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Name.Contains("ayende") && user.Email.Contains("*****@*****.**")
             select user;
     Assert.Equal("Name:ayende AND Email:[email protected]", q.ToString());
 }
Exemplo n.º 3
0
 public void CanUnderstandConvertExpressions()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Age == Convert.ToInt16("3")
             select user;
     Assert.Equal("Age:3", q.ToString());
 }
Exemplo n.º 4
0
 public void CanUnderstandGreaterThan()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null,null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Birthday > new DateTime(2010, 05, 15)
             select user;
     Assert.Equal("Birthday:{20100515000000000 TO NULL}", q.ToString());
 }
Exemplo n.º 5
0
 public void CanUnderstandGreaterThanOnInt()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Age > 3
             select user;
     Assert.Equal("Age_Range:{0x00000003 TO NULL}", q.ToString());
 }
Exemplo n.º 6
0
 public void CanChainMultipleWhereClauses()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = indexedUsers
         .Where(x => x.Age == 3)
         .Where(x => x.Name == "ayende");
     Assert.Equal("Age:3 AND Name:ayende", q.ToString());
 }
Exemplo n.º 7
0
        public void BracesOverrideOperatorPrecedence()
        {
            var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
            var q = from user in indexedUsers
                    where user.Name == "ayende" && (user.Name == "rob" || user.Name == "dave")
                    select user;

            Assert.Equal("Name:ayende AND (Name:rob OR Name:dave)", q.ToString());
        }
Exemplo n.º 8
0
        /// <summary>
        /// Queries the specified index using Linq.
        /// </summary>
        /// <typeparam name="T">The result of the query</typeparam>
        /// <param name="indexName">Name of the index.</param>
        /// <param name="isMapReduce">Whatever we are querying a map/reduce index (modify how we treat identifier properties)</param>
        public IRavenQueryable <T> Query <T>(string indexName, bool isMapReduce = false)
        {
            var ravenQueryStatistics = new RavenQueryStatistics();
            var highlightings        = new RavenQueryHighlightings();
            var ravenQueryProvider   = new RavenQueryProvider <T>(this, indexName, ravenQueryStatistics, highlightings, DatabaseCommands, null, isMapReduce);
            var inspector            = new RavenQueryInspector <T>();

            inspector.Init(ravenQueryProvider, ravenQueryStatistics, highlightings, indexName, null, this, DatabaseCommands, null, isMapReduce);
            return(inspector);
        }
        private IRavenQueryable <T> QueryInternal <T>(IAsyncDatabaseCommands assyncDatabaseCommands, string indexName, bool isMapReduce = false)
        {
            var ravenQueryStatistics = new RavenQueryStatistics();
            var highlightings        = new RavenQueryHighlightings();
            var ravenQueryInspector  = new RavenQueryInspector <T>();
            var ravenQueryProvider   = new RavenQueryProvider <T>(this, indexName, ravenQueryStatistics, highlightings, null, assyncDatabaseCommands, isMapReduce);

            ravenQueryInspector.Init(ravenQueryProvider,
                                     ravenQueryStatistics,
                                     highlightings,
                                     indexName,
                                     null,
                                     this, null, assyncDatabaseCommands, isMapReduce);
            return(ravenQueryInspector);
        }
Exemplo n.º 10
0
 public void NoOpShouldProduceEmptyString()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             select user;
     Assert.Equal("", q.ToString());
 }
Exemplo n.º 11
0
 public void CanUnderstandProjectionOfOneField()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null,null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Birthday >= new DateTime(2010, 05, 15)
             select user.Name;
     Assert.Equal("<Name>: Birthday:[20100515000000000 TO NULL]", q.ToString());
 }
Exemplo n.º 12
0
 public void CanUnderstandMethodCalls()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Birthday >= DateTime.Parse("2010-05-15")
             select new { user.Name, user.Age };
     Assert.Equal("<Name, Age>: Birthday:[20100515000000000 TO NULL]", q.ToString());
 }
Exemplo n.º 13
0
 public void CanUnderstandSimpleAny()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = indexedUsers
         .Where(x => x.Properties.Any(y => y.Key == "first"));
     Assert.Equal("Key:first", q.ToString());
 }
Exemplo n.º 14
0
 public void CanUnderstandSimpleEqualityOnInt()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Age == 3
             select user;
     Assert.Equal("Age:3", q.ToString());
 }
Exemplo n.º 15
0
 public void CanUnderstandSimpleEqualityWithVariable()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
     var ayende = "ayende" + 1;
     var q = from user in indexedUsers
             where user.Name == ayende
             select user;
     Assert.Equal("Name:ayende1", q.ToString());
 }
Exemplo n.º 16
0
 public void CanUnderstandLessThanOrEqualsTo()
 {
     var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null,null, ravenQueryStatistics),  ravenQueryStatistics);
     var q = from user in indexedUsers
             where user.Birthday <= new DateTime(2010, 05, 15)
             select user;
     Assert.Equal("Birthday:[* TO 20100515000000000]", q.ToString());
 }
Exemplo n.º 17
0
        public void WithNoBracesOperatorPrecedenceIsHonoured()
        {
            var indexedUsers = new RavenQueryInspector<IndexedUser>(new RavenQueryProvider<IndexedUser>(null, null, ravenQueryStatistics),  ravenQueryStatistics);
            var q = from user in indexedUsers
                    where user.Name == "ayende" && user.Name == "rob" || user.Name == "dave"
                    select user;

            Assert.Equal("(Name:ayende AND Name:rob) OR Name:dave", q.ToString());
        }