Chr*_*way 6 c# entity-framework cancel-button sql-server-2008 long-running-processes
我创建了一个应用程序(Windows,WPF),它基本上是数据库(Sql Server)中数据的查看器.该应用程序没有编辑功能.
该应用程序提供了根据用户输入搜索记录的功能.在大多数情况下,行由键列搜索并运行得非常快.但是表中的一列是一个大文本字段,我希望能够根据该字段的内容搜索行.因此,生成的SQL查询可能需要一些时间才能完成.我想提供一个停止按钮,以便用户可以根据需要中止搜索.我在上面放置的链接使用Kill命令来杀死Sql server中的spid,但是我不确定这在我的情况下是如何工作的,因为我使用的是Entity Framework(4.1)
例如,假设有一个类似于此的查询:
var docs = from document in context.Documents
join header in context.Headers
on document.DocumentID equals header.HeaderID into headerGroup
from subdoc in headerGroup.DefaultIfEmpty()
where document.LargeTextColumn.Contains("search term")
select (...)
foreach (var item in docs)
{
//Do something with item here
}
Run Code Online (Sandbox Code Playgroud)
由于查询实际上没有发生,直到我使用foreach语句迭代它,如何为用户提供"停止查询"按钮?这类似于Sql Server Management Studio中的停止按钮.
这可能吗?