Entity Framework 5, Code First, Full Text Search but IQueriable via CreateQuery?-Collection of common programming errors
Thanks NSGaga, adding VALUE help resolve this issue, but there was still some problem, and after some more researching I found query that works (just add ‘as movie’ at end):
@"SELECT VALUE movie FROM Movies as movie"
Anyone who need this, take into consideration that table name is ‘Movie’ and that ‘Movies’ is name of DbSet in DbContext.
Now it works for queries like this, however I still didn’t resolve it for FTS. For DB I am using Potgresql and FTS is implemented using tsvector. Anyway standard query in PGadmin is:
SELECT * FROM dbo."Movie" WHERE title_tsvector @@ to_tsquery('incept:*');
So here I put:
@"SELECT VALUE movie FROM Movies as movie WHERE title_tsvector @@ to_tsquery('incept:*')"
But it does not work, get error:
System.Data.EntitySqlException was unhandled
HResult=-2146232006
Message=The query syntax is not valid., line 1, column 61
Source=System.Data.Entity
Column=0
ErrorContext=""
ErrorDescription=""
Line=0
StackTrace: at System.Data.Common.EntitySql.CqlLexer.yylex()
It seems the problem is that EF is not aware of tsvector, what is additional column in this table.
- Is there any solution for this?
- I could put this select and where query into stored procedure but I couldn’t call that either from CreateQuery ?