Search code examples
linqt-sqlentity-framework-6contains

How to use contains (T-SQL) in Entity Framework


I am looking for the equivalent of this feature of T-SQL:

SELECT * 
FROM dbo.users 
WHERE CONTAINS (name, 'Jack')

in Entity Framework.

Thanks.

P.S. "contains" in linq is equivalent of LIKE in TSQL (eg., '%jack%'). I'm not looking for this because this kind of search, especially on large databases may affect the performance.


Solution

  • The CONTAINS keyword is part of the full-text search capability in SQL Server - and as of this day, EF doesn't natively support full-text searching.

    There are some approaches out there using EF "interceptors" or plain and simple T-SQL stored procedure to include this functionality into EF - but it's not part of the EF package provided by Microsoft.

    See these other SO questions: