我正在使用 SqlDependency 类,并一直在尝试查找 类型,来源 和 Info SqlNotificationEventArgs 对象。
这是迄今为止我找到的最接近的。但是,我知道这并不能涵盖所有内容,因为我已经看到了更改/客户端/错误的组合。
我真的很想知道我是否以最佳方式处理所有可能的情况。也就是说,只要有可能,我想重新建立“订阅”。
例如,更改/客户端/错误是针对网络问题执行的,该问题中断了 SqlServer 和我的应用程序之间的通信。一旦通讯重新建立,我就能成功康复。
编辑:
如果我举一些我所担心的例子,也许会有所帮助。
对于以下问题,当我说“恢复”时,我的意思是在运行时重新建立订阅,即无需手动干预。
I'm using the SqlDependency class and have been trying unsuccessfully to find a list of possible combinations of the Type, Source and Info properties of the SqlNotificationEventArgs object.
This is the closest I've found so far. However, I know this doesn't cover everything because I've already seen the combination Change/Client/Error.
I'd really like to know if I'm handling all possible cases in the best possible way. That is, whenever possible I'd like to reestablish the "subscription".
For instance the Change/Client/Error was do to a network issue that interrupted communication between SqlServer and my app. Once communication was reestablished I was able to recover successfully.
EDIT:
Maybe it would help if I gave some examples of the concerns I have.
For the following questions when I say "recover" I mean reestablish a subscription at runtime, that is without manual intervention.
- Is it safe to assume that a Type of
Subscribe
means there is nothing I can do to recover.
- Is it safe to assume that a Source of
Data
will always have a Info of truncate
, insert
, update
, or delete
. If not will it always be something similar. I don't currently distinguish between these cases and I just reestablish the subscription and fetch the updated data.
- Is it safe to assume that, with the possible exception of an Info of
Alter
, a Source of object
means that my query is no longer valid and I won't be able to recover.
发布评论
评论(1)
类型可以是以下任意一种:更改、订阅或未知
源可以是以下任意一个:数据、超时、对象、数据库、系统、语句、环境、执行、所有者、未知或客户端
信息可以是以下任意一种:截断、插入、更新、删除、删除、更改、重新启动、错误、查询、无效、选项、隔离、过期、资源、PreviousFire、TemplateLimit、合并、未知或已经改变
最后,在回答您的问题时,列出了可能的组合:
来源:SqlNotificationType 枚举,SqlNotificationSource 枚举、SqlNotificationInfo 枚举 和 SqlNotificationType.cs,SqlNotificationInfo.cs ,SqlNotificationSource.cs
Type can be any of: Change, Subscribe, or Unknown
Source can be any of: Data, Timeout, Object, Database, System, Statement, Environment, Execution, Owner, Unknown, or Client
Info can be any of: Truncate, Insert, Update, Delete, Drop, Alter, Restart, Error, Query, Invalid, Options, Isolation, Expired, Resource, PreviousFire, TemplateLimit, Merge, Unknown, or AlreadyChanged
And finally, in answer to your question a list of possible combinations:
Sources: SqlNotificationType Enumeration, SqlNotificationSource Enumeration, SqlNotificationInfo Enumeration and SqlNotificationType.cs, SqlNotificationInfo.cs, SqlNotificationSource.cs