SQLDependency Notification [Invalid,Statement,Subscribe] [英] SQLDependency Notification [Invalid, Statement, Subscribe]

查看:107
本文介绍了SQLDependency Notification [Invalid,Statement,Subscribe]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想知道你是否可以帮助我,因为我现在有点难过。

我是尝试使用SQLDependency对象编写一个Windows服务,用于在表中创建条目时发送电子邮件。



我的DAL是使用Entity生成的框架版本5,正在为一个对象工作。但是我现在尝试重复另一个对象的过程,一旦我的通知程序尝试注册查询,我就会收到以下错误:



Hi Guys,

I was wondering if you could help me as I am a bit stumped at the moment.
I am trying to use the SQLDependency object(s) to write a windows service for sending e-mails upon the creation of entries in a table.

My DAL is produced using Entity Framework version 5 and is working for one object. However I have now tried to repeat the process for another object and as soon as my Notifier tries to register the query, I am getting the following error:

[Invalid, Statement, Subscribe]:
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Sid] AS [Sid],
[Extent1].[Created] AS [Created],
[Extent1].[LastUpdated] AS [LastUpdated],
[Extent1].[Completed] AS [Completed],
[Extent1].[Private] AS [Private],
[Extent1].[Status] AS [Status]
FROM [dbo].[Initiatives] AS [Extent1]
WHERE ( NOT ([Extent1].[Id] IN (22,24,25,38,39,40,41,42,43,44,45,47))) AND ( EXISTS (SELECT
        1 AS [C1]
        FROM [dbo].[InitiativeAnswers] AS [Extent2]
        WHERE [Extent1].[Id] = [Extent2].[CompletedId]
))





现在,在为了进入这个阶段,我正在使用此Code Pr中的EFChangeNotify oject文章:

SqlDependency with Entity Framework 5.0 [ ^ ]



这是导致上述错误的C#代码:



Now, in order to get to this stage I am using the EFChangeNotify from this Code Project Article:
SqlDependency with Entity Framework 5.0[^]

This is the C# code that is resulting in the above error:

using (var initiativeCreationMonitor = 
       new EntityChangeNotifier<Initiative, Task_Entities>(
            i => !InitiativeIds.Contains(i.Id) && i.InitiativeAnswers.Any()))
{

}





我有过环顾四周,并试图了解为什么这不会起作用,似乎没有什么可以跳出来作为一个原因。您可以看到查询使用SQL依赖项所需的Scheme.TableName方法。现在我能想到的唯一一件事就是我试图同时查询2个表。虽然我没有发现任何可以说这是不可能的,但这似乎是基于我得到的结果的逻辑假设。



有没有人有这方面的经验对于如何解决这个问题,我有什么想法?不幸的是我无法改变我理想情况下的数据库结构。



I've had a look around and tried to see why this would not work and nothing seems to jump out as a cause. the query, as you can see uses the Scheme.TableName approach which is required for SQL Dependency. Now the only thing I can think of that is causing it is that I am trying to query 2 tables at the same time. Although I have not found anything to say this is not possible, it seems like the logical assumption based on the results I am getting.

Does anyone have any experience with this sort of thing, or have any ideas on how I can work around the issue? Unfortunately I am not able to change the database structure which I ideally would.

推荐答案

你好,如果我理解正确,问题出在你的查询中,因为SqlDependency没有允许子查询。

我认为这个链接 [ ^ ]可以帮助您。
hello, if I understand correctly, the problem is in your query, because SqlDependency does not allow subqueries.
I think this link[^] can help you.

这篇关于SQLDependency Notification [Invalid,Statement,Subscribe]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆