RavenDB version 2.0. Other versions:

How to index across entities?

RavenDB allows you to easily index a single entity by specifying:

from user in docs.Users
select new { user.Name}

But what happen if you want to index Users or Employees? You can do that easily enough using:

from doc in docs
let entityName = doc["@metadata"]["Raven-Entity-Name"]
where entityName == "Users" || entityName == "Employees"
select new { doc.Name }

This method allow you to index all users and all employees in the same index, and queries on this index will be able to find either type of documents.

Comments add new comment

The comments section is for user feedback or community content. If you seek assistance or have any questions, please post them at our support forums.

No comments found
SUBMIT COMMENT