public IEnumerable <Contact> Search(string pattern, int maxRows) { QueryOver <Contact, Contact> defaultQuery = new DefaultQueryOver <Contact, int>().GetQueryOver(); if (maxRows == 0) { maxRows = int.MaxValue; } var searchIds = this._fullTextModel.Search(pattern, typeof(Contact), maxRows).ToList(); defaultQuery = defaultQuery.WhereRestrictionOn(x => x.Id).IsIn(searchIds); return(searchIds.Any() ? this.Repository.FindAll(defaultQuery).ToList().OrderBy(x => searchIds.IndexOf(x.Id)) : this.Repository.FindAll(defaultQuery)); }