예제 #1
0
        private ActionResult Rss(RavenQueryStatistics stats, IEnumerable<Post> posts)
        {
            string requestETagHeader = Request.Headers["If-None-Match"] ?? string.Empty;
            var responseETagHeader = stats.Timestamp.ToString("o");
            if (requestETagHeader == responseETagHeader)
                return HttpNotModified();

            var rss = new XDocument(
                new XElement("rss",
                             new XAttribute("version", "2.0"),
                             new XElement("channel",
                                          new XElement("title", GetBlogTitle()),
                                          new XElement("link", Request.ApplicationPath),
                                          new XElement("description", GetBlogTitle()),
                                          new XElement("copyright", String.Format("{0} (c) {1}", GetBlogCopyright(), DateTime.Now.Year)),
                                          new XElement("ttl", "60"),
                                          from post in posts
                                          select new XElement("item",
                                                              new XElement("title", post.Title),
                                                              new XElement("description", post.Body),
                                                              new XElement("link", GetPostLink(post)),
                                                              new XElement("pubDate", post.PublishAt.ToString("R"))
                                          	)
                             	)
                    )
                );

            return Xml(rss, responseETagHeader);
        }
        public void Getting_Statistics_From_A_Query()
        {
            using (var session = Store.OpenSession())
            {
                var stats = new RavenQueryStatistics();

                var contacts = session.Query<Employee>()
                                    .Statistics(out stats)
                                    .Where(x => x.Email == "*****@*****.**")
                                    .ToList();

                Console.Out.WriteLine(stats.IndexName);
                Console.Out.WriteLine(stats.IsStale);
            }
        }
        /// <summary>
        /// Creates a dynamic query provider around the provided document session
        /// </summary>
        public DynamicRavenQueryProvider(
            IDocumentQueryGenerator queryGenerator,
            string indexName,
            RavenQueryStatistics ravenQueryStatistics
#if !SILVERLIGHT
            , IDatabaseCommands databaseCommands
#endif
#if !NET_3_5
            , IAsyncDatabaseCommands asyncDatabaseCommands
#endif
            )
        {
            FieldsToFetch             = new HashSet <string>();
            this.queryGenerator       = queryGenerator;
            this.indexName            = indexName;
            this.ravenQueryStatistics = ravenQueryStatistics;
#if !SILVERLIGHT
            this.databaseCommands = databaseCommands;
#endif
#if !NET_3_5
            this.asyncDatabaseCommands = asyncDatabaseCommands;
#endif
        }
예제 #4
0
 /// <summary>
 /// Provide statistics about the query, such as total count of matching records
 /// </summary>
 public IRavenQueryable <T> Statistics(out RavenQueryStatistics stats)
 {
     stats = queryStats;
     return(this);
 }
 private bool CheckEtag(RavenQueryStatistics stats, out string responseETagHeader)
 {
     string requestETagHeader = Request.Headers["If-None-Match"] ?? string.Empty;
     responseETagHeader = stats.Timestamp.ToString("o") + EtagInitValue;
     return requestETagHeader == responseETagHeader;
 }