I have this Document table with some meta data for the document in it and also the document content as a blob.
then I use lucene.Net to query my documents; which in return gives me a list of Guids to my Document table and also two fields containing the highlighted html versions of the document name and extract with the search keywords highlighted.
then I use linq to join this result with my document table fields to get a list to show as the search result. stupid thing is linq tries to load the blob to the document although it's not used in the join.
I'm thinking of two options, neither of them I like:
- move my blob to a new table and link it 1-1 to the document table. which I don't like because the limitation in linq is forcing me to change my db structure.
- add a new dbml with a "LiteDocument" table in it and remove the blob from the document table in dbml; which I don't like because I have two places to maintain if document table has a change.
I was wondering if there is a better way to do this? here are the code snippets:
public class LuceneSearchResult
{
public Guid DocumentID { get; set; }
public string FormattedDocumentFileName { get; set; }
public string FormattedDocumentExtract { get; set; }
}
and
public IList Search(string searchPhrase, Guid? ProductId)
{
searchPhrase = PrepareSearchPhraseWithThesaurus(searchPhrase);
var result = RunLuceneQuery(searchPhrase, ProductId);
var dc = new ChinaHcpDataContext();
var docs =
from r in result
join d in dc.Documents on r.DocumentID equals d.DocumentID
select
new
{
d.DocumentID,
TradeNameEN = d.TradeProduct != null ? d.TradeProduct.TradeNameEN : "",
TradeNameZH = d.TradeProduct != null ? d.TradeProduct.TradeNameZH : "",
d.DocumentFileName,
d.InsertedDateUtc,
d.Size,
DocumentDisplayText = r.FormattedDocumentFileName,
DocumentSelectionReason = r.FormattedDocumentExtract
};
return docs.ToList();
}