Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > General> Fulltext - query all columns
 

Pages: 1
General
Fulltext - query all columns
Page:1/1 

  Print all messages in this thread  
Poster Message
JRR
User



Location:
Western Canada
Joined on:
07-Dec-2005 23:33:05
Posted:
125 posts
# Posted on: 08-Apr-2009 04:05:50.  

Consider this sql predicate:
Code:

Contains(*,N'SearchText')


This thread - http://llblgen.com/tinyforum/Messages.aspx?ThreadID=13883
demonstrates how we can use multiple columns in a predicate with FieldFullTextSearchPredicate, but what about a wildcard (*) where all columns are used?

That way we don't have to code in each column manually.

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13672 posts
# Posted on: 08-Apr-2009 10:17:43.  
You can use Linq for this.

The example in the docs can be modified as such:
Code:
/// Class which is used to specify the call to the CONTAINS construct.
public class NorthwindFunctions
{
    public static bool FullTextSearch(string toFind)
    {
        // empty body, as it's just here to make the query compile. The call is converted to a SQL function.
        return true;
    }
}

/// Class which defines the custom mapping between NorthwindFunctions.FullTextSearch and CONTAINS()
public class NorthwindFunctionMappings : FunctionMappingStore
{
    public NorthwindFunctionMappings() : base()
    {        
         this.Add(new FunctionMapping(typeof(NorthwindFunctions), "FullTextSearch", 1, "CONTAINS(*, {0})"));
    }
}


//...

// these constructs are now allowing the developer to actually call CONTAINS from within
// the Linq query. We have to pass the custom FunctionMappingStore 'NorthwindFunctionMappings' to
// the LinqMetaData first:
metaData.CustomFunctionMappings = new NorthwindFunctionMappings();
// fetch the employees which have 'BA' in their Notes field which is Full text search enabled.
var q = from e in metaData.Employee
        where NorthwindFunctions.FullTextSearch("BA")
        select e;


  Top
JRR
User



Location:
Western Canada
Joined on:
07-Dec-2005 23:33:05
Posted:
125 posts
# Posted on: 08-Apr-2009 16:05:38.  
Thanks for the reply. I haven't learned linq yet, still using straight llblgen for data calls. Will this fulltext function class be callable from a standard predicate expression?
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13672 posts
# Posted on: 08-Apr-2009 16:30:43.  
Nope, this function mapping is used from Linq only.

But you can try to cook this using a DBFunctionCall as an expression, and using constants for function parameters


  Top
JRR
User



Location:
Western Canada
Joined on:
07-Dec-2005 23:33:05
Posted:
125 posts
# Posted on: 09-Apr-2009 08:40:52.  
Since this doesn't work:

Code:

select * from dbo.myTable
where CONTAINS(*,'text') = 1;


How can I include a function call as a predicate without assigning values?

I can create the function in c#:

Code:
DbFunctionCall containsFunction = new DbFunctionCall("CONTAINS", new object[] { "*", value });


but how does I include it in a predicate?
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13672 posts
# Posted on: 09-Apr-2009 11:24:27.  
I thought something like the following should work?
Code:
select * from dbo.myTable
where CONTAINS(*,'text') = true


Another option is to derive your own class from the FieldFullTextSearchPredicate class, and override the ToQueryText() method.


  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.