Skip to content
Advertisement

Link To Entities, how to fix Startswith resolving to sql CHARINDEX and ignoring index

I have the following model

I’m calling this function

The above is trying to reproduce the following sql

However it’s generating the following nasty piece of work:

As you can see, it’s generating CHARINDEX for the StartsWith.

The problem is this is ignoring all the indexing I have setup, and takes many seconds to run on 5 million records.

How could I take advantage of Link To Entities, and have my above requirements satisfied including the indexes?

The only thing I can think of is to use a stored procedure, or a raw SQL statement, which defeats the whole entity thing.

Advertisement

Answer

The only suitable solution i have found so far is the following

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement