Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you query with this form:</p> <pre class="lang-cs prettyprint-override"><code>session.Query&lt;Entity&gt;("IndexName") </code></pre> <p>You are asking for <em>all</em> items of that index to be returned from the query, and then telling the RavenDB client to deserialize them <em>all</em> as the type you specified.</p> <p>Normally, that works out quite well because a specific index would be built for the types you're working with. For example, you would usually build your own index of subscriptions for a specific purpose, and query that:</p> <pre class="lang-cs prettyprint-override"><code>session.Query&lt;Subscription&gt;("Subscriptions/ByWhatever") </code></pre> <p>or if you built the index from C#, you might like this syntax instead to avoid the string:</p> <pre class="lang-cs prettyprint-override"><code>session.Query&lt;Subscription, Subscriptions_ByWhatever&gt;() </code></pre> <p>You could also just let Raven build an index for you automatically:</p> <pre class="lang-cs prettyprint-override"><code>session.Query&lt;Subscription&gt;() </code></pre> <p>Since you used the built-in <code>Raven/DocumentsByEntityName</code> index, you are returning all documents in the database, not just those that are subscriptions. Since only some can be deserialized as a <code>Subscription</code> type, the others are failing with serialization errors.</p> <p>If you'd like to continue to use that index, you would need to filter it to just those of that type:</p> <pre class="lang-cs prettyprint-override"><code>session.Advanced.LuceneQuery&lt;Subscription&gt;("Raven/DocumentsByEntityName") .WhereEquals("Tag", "Subscriptions") </code></pre> <p>The <code>LuceneQuery</code> form is easier here, since you are filtering a field by its string name. </p> <p>You could use a regular LINQ query, but you'd have to create a type that contains the <code>Tag</code> field, like this:</p> <pre class="lang-cs prettyprint-override"><code>class RDBENIndexEntry { public string Tag { get; set; } } ... session.Query&lt;RDBENIndexEntry&gt;("Raven/DocumentsByEntityName") .Where(x =&gt; x.Tag == "Subscriptions").OfType&lt;Subscription&gt;() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload