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 8936587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:14:44+00:00 2026-06-15T10:14:44+00:00

I have a document in RavenDB that looks looks like: { ItemId: 1, Title:

  • 0

I have a document in RavenDB that looks looks like:

{
    "ItemId": 1,
    "Title": "Villa
}

With the following metadata:

Raven-Clr-Type: MyNamespace.Item, MyNamespace
Raven-Entity-Name: Doelkaarten

So I serialized with a type MyNamespace.Item, but gave it my own Raven-Entity-Name, so it get its own collection.

In my code I define an index:

public class DoelkaartenIndex : AbstractIndexCreationTask<Item>
{
    public DoelkaartenIndex()
    {
        // MetadataFor(doc)["Raven-Entity-Name"].ToString() == "Doelkaarten"
        Map = items => from item in items
                       where MetadataFor(item)["Raven-Entity-Name"].ToString() == "Doelkaarten"
                       select new {Id = item.ItemId, Name = item.Title};
    }
}

In the Index it is translated in the “Maps” field to:

docs.Items
.Where(item => item["@metadata"]["Raven-Entity-Name"].ToString() == "Doelkaarten")
.Select(item => new {Id = item.ItemId, Name = item.Title})

A query on the index never gives results.

If the Maps field is manually changed to the code below it works…

from doc in docs
where doc["@metadata"]["Raven-Entity-Name"] == "Doelkaarten"
select new { Id = doc.ItemId, Name=doc.Title };

How is it possible to define in code the index that gives the required result?

RavenDB used: RavenHQ, Build #961

UPDATE:

What I’m doing is the following: I want to use SharePoint as a CMS, and use RavenDB as a ready-only replication of the SharePoint list data. I created a tool to sync from SharePoint lists to RavenDB. I have a generic type Item that I create from a SharePoint list item and that I serialize into RavenDB. So all my docs are of type Item. But they come from different lists with different properties, so I want to be able to differentiate. You propose to differentiate on an additional property, this would perfectly work. But then I will see all list items from all lists in one big Items collection… What would you think to be the best approach to this problem? Or just live with it? I want to use the indexes to create projections from all data in an Item to the actual data that I need.

  • 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-15T10:14:45+00:00Added an answer on June 15, 2026 at 10:14 am

    You can’t easily change the name of a collection this way. The server-side will use the Raven-Entity-Name metadata, but the client side will determine the collection name via the conventions registered with the document store. The default convention being to use the type name of the entity.

    You can provide your own custom convention by assigning a new function to DocumentStore.Conventions.FindTypeTagName – but it would probably be cumbersome to do that for every entity. You could create a custom attribute to apply to your entities and then write the function to look for and understand that attribute.

    Really the simplest way is just to call your entity Doelkaarten instead of Item.

    Regarding why the change in indexing works – it’s not because of the switch in linq syntax. It’s because you said from doc in docs instead of from doc in docs.Items. You probably could have done from doc in docs.Doelkaartens instead of using the where clause. They are equivalent. See this page in the docs for further examples.

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

Sidebar

Related Questions

In RavenDB, I have a document that looks like this: public class SystemNotification {
I have something that looks like the following document structure: public class Document {
The sample db that comes with RavenDB has Albums document collection, that each have
I have documents in RavenDb that may look something like this: { Id: obj/1,
I have a document class that contains a list of tags. Something like: class
I have documents collection Messages in my base (RavenDB) Document definition like: class Message
I have a RavenDB mvc applicaton that has a document entity called Member. Each
I have a document type of info I also have some custom properites. infoTitle
i have a document like this: English English English English 中文中文中文中文中文 English English English
I have a document, something like this: <root> <A node=1/> <B node=2/> <A node=3/>

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.