[英]Sql Server Freetext through Entity Framework
I have an existing website developped using ASP.NET MVC 3 and Entity Framework 4 querying an Sql Server 2008 database. 我有一个使用ASP.NET MVC 3和Entity Framework 4查询Sql Server 2008数据库的现有网站。 It contains a search form with around 10 fields, and when the user clicks the submit button I dynamically create an Entity SQL request containing only the specified search fields, omitting the empty ones.
它包含一个带有大约10个字段的搜索表单,当用户单击“提交”按钮时,我动态创建了一个仅包含指定搜索字段的Entity SQL请求,省略了空字段。 It works.
有用。 So far so good.
到目前为止,一切都很好。
Now, the client wants a Full Text Search behavior for one of the fields. 现在,客户希望其中一个字段具有“全文本搜索”行为。 I see this request as being pretty complex because (AFAIK) :
我认为此请求非常复杂,因为(AFAIK):
Solutions I could think of so far : 到目前为止我能想到的解决方案:
What's the best way for daeling with this ? 敢于这样做的最好方法是什么?
Can you not just use raw sql? 您不仅可以使用原始sql吗? then you can keep the logic in your .NET code.
那么您可以将逻辑保留在.NET代码中。
So, it would look something like: 因此,它看起来像:
string sql = "DO FULLTEXT STUFF";
MyObjectContext.ExecuteStoreQuery<MyEntity>(sql, .......);
You don't have to think about performance - this will be slow anyway because you will be replacing indexed full text search with standard string comparing on concatenated value. 您不必考虑性能-无论如何这都会很慢,因为您将用标准字符串对串联值进行比较来替换索引的全文本搜索。
There are three ways to go: 共有三种方法:
Any of this methods is not solution for performance. 这些方法都不是性能的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.