I'm using FluentNHibernate and I have just moved to NHibernate 3.0. I have also changed my d开发者_Go百科atabase schema to a table-per-subclass configuration which I really like. We used full-text search before using MS SQL 2005's built in full-text search which worked fine because all of our content was of one class and one table. Now that our data is spread out among different subclasses/tables with different fields to be indexed on each class we will typically want one search against all subclasses. What is the best way to accomplish this and how would I query it?
We have been using Linq more lately but I would be OK with HQL.
I eventually solved this by chaining by HQL queries like this...
string selectCat = @"from Cat c where freetext((c.Name),:keyword)";
string selectDog = @"from Dog d where freetext((d.Name,d.OwnerName),:keyword)";
var animals = session.CreateQuery(selectCat).SetString("keyword", keyword).List<BaseAnimal>().Concat<BaseAnimal>(session.CreateQuery(selectDog).SetString("keyword", keyword).List<BaseAnimal>()).ToList<BaseAnimal();
精彩评论