Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:06:40+00:00 2026-06-18T15:06:40+00:00

RavenDB provides 2 APIs for querying data, IDocumentQuery<T> for advanced lucene query and IRavenQueryable<T>

  • 0

RavenDB provides 2 APIs for querying data, IDocumentQuery<T> for advanced lucene query and IRavenQueryable<T> for a strongly typed linq provider model.

They share a method called Statistics(out RavenQueryStatistics stats) that returns information at run time.

The 2 different method signatures are:

  public interface IRavenQueryable<T> ....
  {
    IRavenQueryable<T> Statistics(out RavenQueryStatistics stats);

and

 public interface IDocumentQueryBase<T, out TSelf> 
                          where TSelf : IDocumentQueryBase<T, TSelf>
  {
    TSelf Statistics(out RavenQueryStatistics stats);

I’m starting off with

    protected override dynamic SetupQuery(IDocumentSession session)
    {
        return session.Advanced.LuceneQuery<Foo>(new FooIndex().IndexName)
               .WhereEquals("Bar", "Baz")
               ;            
    }

The intent is that this method is able to be replaced by other classes.

I am attempting to consume this as such:

using (var session = Store.OpenSession())
{
    RavenQueryStatistics stats=null;
    var dynQuery=    SetupQuery(session);
    var dynQuery2 = dynQuery.Statistics(out stats);
    //Results in cannot cast void to object

    //next i tried using reflection
    var refQuery=    SetupQuery(session);
    MethodInfo methodInfo = refQuery.GetType()
            .GetMethod("Statistics", BindingFlags.Public, null, 
            new[] {typeof (RavenQueryStatistics).MakeByRefType()}, null);


    var refQuery2= methodInfo.Invoke(query, new[] {stats});
    //results in NullReferenceException
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:06:41+00:00Added an answer on June 18, 2026 at 3:06 pm

    You are looking at the interface definitions, but as it turns out, the dynamic calls end up calling AbstractDocumentQuery.Statistics, which returns void.
    The method that returns an instance is actually implemented as explicit interface method, so the dynamic call can’t call it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the http api to query ravendb (so a LINQ query is
In this RavenDB post , Ayende uses a .As call to push the data
We're using RavenDB saga storage, but the saga data isn't being persisted after the
This query is failing (RavenDB 1.0.701) var items= RavenSession.Query<Item>().Where(x => 161 193.StartsWith(x.MaterializedPath)).ToList(); Is there
I'm a little confused about the level of integration between Lucene.NET and RavenDB. Lucene
While querying RavenDB I am noticing that it does not get the expected results
I am trying to query RavenDB on a Datetime which is being offset by
How do queries work in sharded RavenDB setup? I know Raven uses lucene for
I am creating a custom Data Service Provider for some data structure which is
I have an Asp.Net MVC3 application that use embedded RavenDB to store data. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.