I am in process of looking how to retire the LIKE %% search that currently in nop in favor of SQL Server full text search. The motivation is that search is very important in any store so we need to make it easy for customer to find what they want to buy if we want them to buy it. In Nop 1.8/1.9 it was pretty easy case we had all search logic in DB in Stored Procedure. Now it's a bit more uphill :/
This is a piece of code that is currently responsible for search in NOP2:
////searching by keyword
if (!String.IsNullOrWhiteSpace(keywords))
{
query = from p in query
//join pv in _productVariantRepository.Table on p.Id equals pv.ProductId into p_pv
//from pv in p_pv.DefaultIfEmpty()
from pv in p.ProductVariants.DefaultIfEmpty()
where (p.Name.Contains(keywords)) ||
(searchDescriptions && p.ShortDescription.Contains(keywords)) ||
(searchDescriptions && p.FullDescription.Contains(keywords)) ||
(pv.Name.Contains(keywords)) ||
(searchDescriptions && pv.Description.Contains(keywords))
select p;
//TODO search localized values
}
I've googled around a bit and found this:
http://sqlblogcasts.com/blogs/simons/archive/2008/12/18/LINQ-to-SQL---Enabling-Fulltext-searching.aspx
It pretty much says we need to make table valued function in SQL and call it from LINQ.
Piece of cake .. but we're using EF4 Code First .. how do I map a SP to there? Here it says you can't:
http://stackoverflow.com/questions/4845246/does-entity-framework-code-first-support-stored-procedures
.. unless I have access to underlying objectcontext.
So here comes the big question - how do I get hold of object context in ProductService? The last time I asked a similar question Anrei said not to and had me write 8 classes in 5 places to get a row of data from db ;-)
Filip