开发者

Using polymorphic queries over interfaces in RavenDB

开发者 https://www.devze.com 2023-04-05 01:04 出处:网络
I\'m interested in switching over our application (or parts of it) to use RavenDB from SQL server with NHibernate.

I'm interested in switching over our application (or parts of it) to use RavenDB from SQL server with NHibernate.

The key feature that I can't seem to find in Raven is the usage of interfaces for queries eg:

开发者_开发百科
ISearchable
{
  string Name {get;set;}
}

Class1 : ISearchable
{
  string Name {get;set;}
}
Class2 : ISearchable
{
   string Name {get;set;}
}

In NH I can search for the contents of the Name field in any ISearchable: QueryOver<ISearchable>().

I can't seem to find this in Raven, am I missing something? The closest that I've found is changing the string part at the front of the identifier, which I don't want to do; the main function of Class1 and Class2 is not to be searchable!

Thanks

Stu


Define an index like:

// ByName
from doc in docs
select new { doc.Name }

session.Query("ByName");

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号