Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:05:21+00:00 2026-06-06T15:05:21+00:00

I am trying to import SQL Server’s CONTAINS() function in my Entity Framework model

  • 0

I am trying to import SQL Server’s CONTAINS() function in my Entity Framework model so that I can use it in my LINQ queries.

I have added this to my EDM:

<Function Name="FullTextSearch" ReturnType="Edm.Boolean">
    <Parameter Name="Filter" Type="Edm.String" />
    <DefiningExpression>
        CONTAINS(*, Filter)
    </DefiningExpression>
</Function>

Add created my method stub:

[EdmFunction("MyModelNamespace", "FullTextSearch")]
public static bool FullTextSearch(string filter)
{
    throw new NotSupportedException("This function is only for L2E query.");
}

I try to call the function like this:

from product in Products
where MyModel.FullTextSearch("FORMSOF(INFLECTIONAL, robe)")
select product

The following exception is raised:

The query syntax is not valid. Near term '*'

I realize that the function I defined is not directly linked to the entity set being queried so that could also be a problem.

Is there any way to pull this off?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:05:23+00:00Added an answer on June 6, 2026 at 3:05 pm

    The function you have defined above uses Entity SQL, not Transact SQL, so I think the first step is to figure out whether CONTAINS(*,’text’) can be expressed in Entity SQL.

    Entity SQL doesn’t support the * operator as described here: http://msdn.microsoft.com/en-us/library/bb738573.aspx and if I try

    entities.CreateQuery<TABLE_NAME>("select value t from TABLE_NAME as t where CONTAINS(*, 'text')");
    

    I get the same error you got above. If I try to explicitly pass the column it works:

    entities.CreateQuery<TABLE_NAME>("select value t from TABLE_NAME as t where CONTAINS(t.COLUMN_NAME, 'text')");
    

    But when I look at the SQL it translated it to a LIKE expression.

    ADO.NET:Execute Reader "SELECT 
    [GroupBy1].[A1] AS [C1]
    FROM ( SELECT 
        COUNT(1) AS [A1]
        FROM [dbo].[TABLE_NAME] AS [Extent1]
        WHERE (CASE WHEN ([Extent1].[COLUMN_NAME] LIKE '%text%') THEN cast(1 as bit) WHEN ( NOT ([Extent1].[COLUMN_NAME] LIKE '%text%')) THEN cast(0 as bit) END) = 1
    )  AS [GroupBy1]"
    

    If you cannot express the query using Entity SQL you’ll have to use a Stored Procedure or other mechanism to use Transact SQL directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to use the import wizard of SQL Server 2008 to import
SQL Server 2008 R2 Express Edition. I'm trying to use the import wizard to
I'm trying to use the SQL Server Import Wizard to import flat text file
I am trying to load a file using the SQL Server Import Data function
I am trying to use the MS SQL Server 2005 Import/Export tool to export
I am trying to use BULK INSERT in SQL Server 2008 to import a
I am trying for sqoop import from SQL Server into Hive. When I execute
I'm trying to import IIS logs into SQL Server 2008. I get this error
I've been trying to import a table from oracle 10g into SQL Server 2005
I’m trying to import fixed width data from text file into SQL Server Express

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.