通过子对象搜索nhibernate搜索?
问题描述:
我有这种关系通过子对象搜索nhibernate搜索?
供应商 - >有许多产品
供需双方建立索引和产品进行索引。我需要(老板想要)搜索供应商和所有供应商的产品,并列出最终的供应商。
这是可能在nhibernate.search/Lucene.NET ?? ??
答
是的,它是可能的:http://ayende.com/blog/3992/nhibernate-search
参见给出的示例,IndexEmbedded属性是指“儿童”对象或集合也将被编入索引:
[Indexed]
public class Post
{
[DocumentId]
public virtual int Id { get; set; }
[IndexedEmbedded]
public virtual Blog Blog { get; set; }
[IndexedEmbedded]
public virtual User User { get; set; }
[Field(Index.Tokenized, Store = Store.Yes)]
public virtual string Title { get; set; }
[Field(Index.Tokenized)]
public virtual string Text { get; set; }
public virtual DateTime PostedAt { get; set; }
public virtual ISet<Comment> Comments { get; set; }
[IndexedEmbedded]
public virtual ISet<Category> Categories { get; set; }
[IndexedEmbedded]
public virtual ISet<Tag> Tags { get; set; }
}
由于工作完美:) – Paul 2011-06-10 01:23:41