how to execute Sql Raw Query in Microsoft Entity Model Framework
I'm using Microsoft Entity model framewor开发者_运维技巧k to access my database. I get an issue while i use this execute query command for executing Sql raw query. Let me know how could i resolve it.
svdc.CreateQuery<VideoMasterTable>(
"select * from videomastertable WHERE FREETEXT(*, '"+keyword+"')"
).ToList();
Thanks in Advance,
Kanal
CreateQuery
takes ESQL, not T-SQL. In EF 4 (only), you can use ExecuteStoreQuery
instead.
With CreateQuery method you are creating ObjectQuery wich will be translated to entity sql (ESQL). Entity SQL is not T-SQL. It has different syntax and uses entity operations. Entity Framework doesn't have methods for Full Text Search currently. You can create such methods or use stored procedures and call them using Entity Framework. To create your methods try this article. For using stored procedures with EF check this article.
精彩评论