2011-06-09 106 views
0

我有這種關係通過子對象搜索nhibernate搜索?

供應商 - >有許多產品

供需雙方建立索引和產品進行索引。我需要(老闆想要)搜索供應商和所有供應商的產品,並列出最終的供應商。

這是可能在nhibernate.search/Lucene.NET ?? ??

回答

2

是的,它是可能的: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; } 
} 
+0

由於工作完美:) – Paul 2011-06-10 01:23:41