SqlDependency - How do I interpret the SqlNotificationEventArgs properties?
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 intervent开发者_StackOverflow社区ion.
- 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 oftruncate
,insert
,update
, ordelete
. 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 ofobject
means that my query is no longer valid and I won't be able to recover.
Type can be any of: Change, Subscribe, or Unknown
public enum SqlNotificationType {
Change = 0,
Subscribe = 1,
// use negative values for client-only-generated values
Unknown = -1
}
Source can be any of: Data, Timeout, Object, Database, System, Statement, Environment, Execution, Owner, Unknown, or Client
public enum SqlNotificationSource {
Data = 0,
Timeout = 1,
Object = 2,
Database = 3,
System = 4,
Statement = 5,
Environment = 6,
Execution = 7,
Owner = 8,
// use negative values for client-only-generated values
Unknown = -1,
Client = -2
}
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
public enum SqlNotificationInfo {
Truncate = 0,
Insert = 1,
Update = 2,
Delete = 3,
Drop = 4,
Alter = 5,
Restart = 6,
Error = 7,
Query = 8,
Invalid = 9,
Options = 10,
Isolation = 11,
Expired = 12,
Resource = 13,
PreviousFire = 14,
TemplateLimit = 15,
Merge = 16,
// use negative values for client-only-generated values
Unknown = -1,
AlreadyChanged = -2
}
And finally, in answer to your question a list of possible combinations:
(Change, Data, Truncate), (Change, Data, Insert), (Change, Data, Update), (Change, Data, Delete), (Change, Data, Drop), (Change, Data, Alter), (Change, Data, Restart), (Change, Data, Error), (Change, Data, Query), (Change, Data, Invalid), (Change, Data, Options), (Change, Data, Isolation), (Change, Data, Expired), (Change, Data, Resource), (Change, Data, PreviousFire), (Change, Data, TemplateLimit), (Change, Data, Merge), (Change, Data, Unknown), (Change, Data, AlreadyChanged), (Change, Timeout, Truncate), (Change, Timeout, Insert), (Change, Timeout, Update), (Change, Timeout, Delete), (Change, Timeout, Drop), (Change, Timeout, Alter), (Change, Timeout, Restart), (Change, Timeout, Error), (Change, Timeout, Query), (Change, Timeout, Invalid), (Change, Timeout, Options), (Change, Timeout, Isolation), (Change, Timeout, Expired), (Change, Timeout, Resource), (Change, Timeout, PreviousFire), (Change, Timeout, TemplateLimit), (Change, Timeout, Merge), (Change, Timeout, Unknown), (Change, Timeout, AlreadyChanged), (Change, Object, Truncate), (Change, Object, Insert), (Change, Object, Update), (Change, Object, Delete), (Change, Object, Drop), (Change, Object, Alter), (Change, Object, Restart), (Change, Object, Error), (Change, Object, Query), (Change, Object, Invalid), (Change, Object, Options), (Change, Object, Isolation), (Change, Object, Expired), (Change, Object, Resource), (Change, Object, PreviousFire), (Change, Object, TemplateLimit), (Change, Object, Merge), (Change, Object, Unknown), (Change, Object, AlreadyChanged), (Change, Database, Truncate), (Change, Database, Insert), (Change, Database, Update), (Change, Database, Delete), (Change, Database, Drop), (Change, Database, Alter), (Change, Database, Restart), (Change, Database, Error), (Change, Database, Query), (Change, Database, Invalid), (Change, Database, Options), (Change, Database, Isolation), (Change, Database, Expired), (Change, Database, Resource), (Change, Database, PreviousFire), (Change, Database, TemplateLimit), (Change, Database, Merge), (Change, Database, Unknown), (Change, Database, AlreadyChanged), (Change, System, Truncate), (Change, System, Insert), (Change, System, Update), (Change, System, Delete), (Change, System, Drop), (Change, System, Alter), (Change, System, Restart), (Change, System, Error), (Change, System, Query), (Change, System, Invalid), (Change, System, Options), (Change, System, Isolation), (Change, System, Expired), (Change, System, Resource), (Change, System, PreviousFire), (Change, System, TemplateLimit), (Change, System, Merge), (Change, System, Unknown), (Change, System, AlreadyChanged), (Change, Statement, Truncate), (Change, Statement, Insert), (Change, Statement, Update), (Change, Statement, Delete), (Change, Statement, Drop), (Change, Statement, Alter), (Change, Statement, Restart), (Change, Statement, Error), (Change, Statement, Query), (Change, Statement, Invalid), (Change, Statement, Options), (Change, Statement, Isolation), (Change, Statement, Expired), (Change, Statement, Resource), (Change, Statement, PreviousFire), (Change, Statement, TemplateLimit), (Change, Statement, Merge), (Change, Statement, Unknown), (Change, Statement, AlreadyChanged), (Change, Environment, Truncate), (Change, Environment, Insert), (Change, Environment, Update), (Change, Environment, Delete), (Change, Environment, Drop), (Change, Environment, Alter), (Change, Environment, Restart), (Change, Environment, Error), (Change, Environment, Query), (Change, Environment, Invalid), (Change, Environment, Options), (Change, Environment, Isolation), (Change, Environment, Expired), (Change, Environment, Resource), (Change, Environment, PreviousFire), (Change, Environment, TemplateLimit), (Change, Environment, Merge), (Change, Environment, Unknown), (Change, Environment, AlreadyChanged), (Change, Execution, Truncate), (Change, Execution, Insert), (Change, Execution, Update), (Change, Execution, Delete), (Change, Execution, Drop), (Change, Execution, Alter), (Change, Execution, Restart), (Change, Execution, Error), (Change, Execution, Query), (Change, Execution, Invalid), (Change, Execution, Options), (Change, Execution, Isolation), (Change, Execution, Expired), (Change, Execution, Resource), (Change, Execution, PreviousFire), (Change, Execution, TemplateLimit), (Change, Execution, Merge), (Change, Execution, Unknown), (Change, Execution, AlreadyChanged), (Change, Owner, Truncate), (Change, Owner, Insert), (Change, Owner, Update), (Change, Owner, Delete), (Change, Owner, Drop), (Change, Owner, Alter), (Change, Owner, Restart), (Change, Owner, Error), (Change, Owner, Query), (Change, Owner, Invalid), (Change, Owner, Options), (Change, Owner, Isolation), (Change, Owner, Expired), (Change, Owner, Resource), (Change, Owner, PreviousFire), (Change, Owner, TemplateLimit), (Change, Owner, Merge), (Change, Owner, Unknown), (Change, Owner, AlreadyChanged), (Change, Unknown, Truncate), (Change, Unknown, Insert), (Change, Unknown, Update), (Change, Unknown, Delete), (Change, Unknown, Drop), (Change, Unknown, Alter), (Change, Unknown, Restart), (Change, Unknown, Error), (Change, Unknown, Query), (Change, Unknown, Invalid), (Change, Unknown, Options), (Change, Unknown, Isolation), (Change, Unknown, Expired), (Change, Unknown, Resource), (Change, Unknown, PreviousFire), (Change, Unknown, TemplateLimit), (Change, Unknown, Merge), (Change, Unknown, Unknown), (Change, Unknown, AlreadyChanged), (Change, Client, Truncate), (Change, Client, Insert), (Change, Client, Update), (Change, Client, Delete), (Change, Client, Drop), (Change, Client, Alter), (Change, Client, Restart), (Change, Client, Error), (Change, Client, Query), (Change, Client, Invalid), (Change, Client, Options), (Change, Client, Isolation), (Change, Client, Expired), (Change, Client, Resource), (Change, Client, PreviousFire), (Change, Client, TemplateLimit), (Change, Client, Merge), (Change, Client, Unknown), (Change, Client, AlreadyChanged), (Subscribe, Data, Truncate), (Subscribe, Data, Insert), (Subscribe, Data, Update), (Subscribe, Data, Delete), (Subscribe, Data, Drop), (Subscribe, Data, Alter), (Subscribe, Data, Restart), (Subscribe, Data, Error), (Subscribe, Data, Query), (Subscribe, Data, Invalid), (Subscribe, Data, Options), (Subscribe, Data, Isolation), (Subscribe, Data, Expired), (Subscribe, Data, Resource), (Subscribe, Data, PreviousFire), (Subscribe, Data, TemplateLimit), (Subscribe, Data, Merge), (Subscribe, Data, Unknown), (Subscribe, Data, AlreadyChanged), (Subscribe, Timeout, Truncate), (Subscribe, Timeout, Insert), (Subscribe, Timeout, Update), (Subscribe, Timeout, Delete), (Subscribe, Timeout, Drop), (Subscribe, Timeout, Alter), (Subscribe, Timeout, Restart), (Subscribe, Timeout, Error), (Subscribe, Timeout, Query), (Subscribe, Timeout, Invalid), (Subscribe, Timeout, Options), (Subscribe, Timeout, Isolation), (Subscribe, Timeout, Expired), (Subscribe, Timeout, Resource), (Subscribe, Timeout, PreviousFire), (Subscribe, Timeout, TemplateLimit), (Subscribe, Timeout, Merge), (Subscribe, Timeout, Unknown), (Subscribe, Timeout, AlreadyChanged), (Subscribe, Object, Truncate), (Subscribe, Object, Insert), (Subscribe, Object, Update), (Subscribe, Object, Delete), (Subscribe, Object, Drop), (Subscribe, Object, Alter), (Subscribe, Object, Restart), (Subscribe, Object, Error), (Subscribe, Object, Query), (Subscribe, Object, Invalid), (Subscribe, Object, Options), (Subscribe, Object, Isolation), (Subscribe, Object, Expired), (Subscribe, Object, Resource), (Subscribe, Object, PreviousFire), (Subscribe, Object, TemplateLimit), (Subscribe, Object, Merge), (Subscribe, Object, Unknown), (Subscribe, Object, AlreadyChanged), (Subscribe, Database, Truncate), (Subscribe, Database, Insert), (Subscribe, Database, Update), (Subscribe, Database, Delete), (Subscribe, Database, Drop), (Subscribe, Database, Alter), (Subscribe, Database, Restart), (Subscribe, Database, Error), (Subscribe, Database, Query), (Subscribe, Database, Invalid), (Subscribe, Database, Options), (Subscribe, Database, Isolation), (Subscribe, Database, Expired), (Subscribe, Database, Resource), (Subscribe, Database, PreviousFire), (Subscribe, Database, TemplateLimit), (Subscribe, Database, Merge), (Subscribe, Database, Unknown), (Subscribe, Database, AlreadyChanged), (Subscribe, System, Truncate), (Subscribe, System, Insert), (Subscribe, System, Update), (Subscribe, System, Delete), (Subscribe, System, Drop), (Subscribe, System, Alter), (Subscribe, System, Restart), (Subscribe, System, Error), (Subscribe, System, Query), (Subscribe, System, Invalid), (Subscribe, System, Options), (Subscribe, System, Isolation), (Subscribe, System, Expired), (Subscribe, System, Resource), (Subscribe, System, PreviousFire), (Subscribe, System, TemplateLimit), (Subscribe, System, Merge), (Subscribe, System, Unknown), (Subscribe, System, AlreadyChanged), (Subscribe, Statement, Truncate), (Subscribe, Statement, Insert), (Subscribe, Statement, Update), (Subscribe, Statement, Delete), (Subscribe, Statement, Drop), (Subscribe, Statement, Alter), (Subscribe, Statement, Restart), (Subscribe, Statement, Error), (Subscribe, Statement, Query), (Subscribe, Statement, Invalid), (Subscribe, Statement, Options), (Subscribe, Statement, Isolation), (Subscribe, Statement, Expired), (Subscribe, Statement, Resource), (Subscribe, Statement, PreviousFire), (Subscribe, Statement, TemplateLimit), (Subscribe, Statement, Merge), (Subscribe, Statement, Unknown), (Subscribe, Statement, AlreadyChanged), (Subscribe, Environment, Truncate), (Subscribe, Environment, Insert), (Subscribe, Environment, Update), (Subscribe, Environment, Delete), (Subscribe, Environment, Drop), (Subscribe, Environment, Alter), (Subscribe, Environment, Restart), (Subscribe, Environment, Error), (Subscribe, Environment, Query), (Subscribe, Environment, Invalid), (Subscribe, Environment, Options), (Subscribe, Environment, Isolation), (Subscribe, Environment, Expired), (Subscribe, Environment, Resource), (Subscribe, Environment, PreviousFire), (Subscribe, Environment, TemplateLimit), (Subscribe, Environment, Merge), (Subscribe, Environment, Unknown), (Subscribe, Environment, AlreadyChanged), (Subscribe, Execution, Truncate), (Subscribe, Execution, Insert), (Subscribe, Execution, Update), (Subscribe, Execution, Delete), (Subscribe, Execution, Drop), (Subscribe, Execution, Alter), (Subscribe, Execution, Restart), (Subscribe, Execution, Error), (Subscribe, Execution, Query), (Subscribe, Execution, Invalid), (Subscribe, Execution, Options), (Subscribe, Execution, Isolation), (Subscribe, Execution, Expired), (Subscribe, Execution, Resource), (Subscribe, Execution, PreviousFire), (Subscribe, Execution, TemplateLimit), (Subscribe, Execution, Merge), (Subscribe, Execution, Unknown), (Subscribe, Execution, AlreadyChanged), (Subscribe, Owner, Truncate), (Subscribe, Owner, Insert), (Subscribe, Owner, Update), (Subscribe, Owner, Delete), (Subscribe, Owner, Drop), (Subscribe, Owner, Alter), (Subscribe, Owner, Restart), (Subscribe, Owner, Error), (Subscribe, Owner, Query), (Subscribe, Owner, Invalid), (Subscribe, Owner, Options), (Subscribe, Owner, Isolation), (Subscribe, Owner, Expired), (Subscribe, Owner, Resource), (Subscribe, Owner, PreviousFire), (Subscribe, Owner, TemplateLimit), (Subscribe, Owner, Merge), (Subscribe, Owner, Unknown), (Subscribe, Owner, AlreadyChanged), (Subscribe, Unknown, Truncate), (Subscribe, Unknown, Insert), (Subscribe, Unknown, Update), (Subscribe, Unknown, Delete), (Subscribe, Unknown, Drop), (Subscribe, Unknown, Alter), (Subscribe, Unknown, Restart), (Subscribe, Unknown, Error), (Subscribe, Unknown, Query), (Subscribe, Unknown, Invalid), (Subscribe, Unknown, Options), (Subscribe, Unknown, Isolation), (Subscribe, Unknown, Expired), (Subscribe, Unknown, Resource), (Subscribe, Unknown, PreviousFire), (Subscribe, Unknown, TemplateLimit), (Subscribe, Unknown, Merge), (Subscribe, Unknown, Unknown), (Subscribe, Unknown, AlreadyChanged), (Subscribe, Client, Truncate), (Subscribe, Client, Insert), (Subscribe, Client, Update), (Subscribe, Client, Delete), (Subscribe, Client, Drop), (Subscribe, Client, Alter), (Subscribe, Client, Restart), (Subscribe, Client, Error), (Subscribe, Client, Query), (Subscribe, Client, Invalid), (Subscribe, Client, Options), (Subscribe, Client, Isolation), (Subscribe, Client, Expired), (Subscribe, Client, Resource), (Subscribe, Client, PreviousFire), (Subscribe, Client, TemplateLimit), (Subscribe, Client, Merge), (Subscribe, Client, Unknown), (Subscribe, Client, AlreadyChanged), (Unknown, Data, Truncate), (Unknown, Data, Insert), (Unknown, Data, Update), (Unknown, Data, Delete), (Unknown, Data, Drop), (Unknown, Data, Alter), (Unknown, Data, Restart), (Unknown, Data, Error), (Unknown, Data, Query), (Unknown, Data, Invalid), (Unknown, Data, Options), (Unknown, Data, Isolation), (Unknown, Data, Expired), (Unknown, Data, Resource), (Unknown, Data, PreviousFire), (Unknown, Data, TemplateLimit), (Unknown, Data, Merge), (Unknown, Data, Unknown), (Unknown, Data, AlreadyChanged), (Unknown, Timeout, Truncate), (Unknown, Timeout, Insert), (Unknown, Timeout, Update), (Unknown, Timeout, Delete), (Unknown, Timeout, Drop), (Unknown, Timeout, Alter), (Unknown, Timeout, Restart), (Unknown, Timeout, Error), (Unknown, Timeout, Query), (Unknown, Timeout, Invalid), (Unknown, Timeout, Options), (Unknown, Timeout, Isolation), (Unknown, Timeout, Expired), (Unknown, Timeout, Resource), (Unknown, Timeout, PreviousFire), (Unknown, Timeout, TemplateLimit), (Unknown, Timeout, Merge), (Unknown, Timeout, Unknown), (Unknown, Timeout, AlreadyChanged), (Unknown, Object, Truncate), (Unknown, Object, Insert), (Unknown, Object, Update), (Unknown, Object, Delete), (Unknown, Object, Drop), (Unknown, Object, Alter), (Unknown, Object, Restart), (Unknown, Object, Error), (Unknown, Object, Query), (Unknown, Object, Invalid), (Unknown, Object, Options), (Unknown, Object, Isolation), (Unknown, Object, Expired), (Unknown, Object, Resource), (Unknown, Object, PreviousFire), (Unknown, Object, TemplateLimit), (Unknown, Object, Merge), (Unknown, Object, Unknown), (Unknown, Object, AlreadyChanged), (Unknown, Database, Truncate), (Unknown, Database, Insert), (Unknown, Database, Update), (Unknown, Database, Delete), (Unknown, Database, Drop), (Unknown, Database, Alter), (Unknown, Database, Restart), (Unknown, Database, Error), (Unknown, Database, Query), (Unknown, Database, Invalid), (Unknown, Database, Options), (Unknown, Database, Isolation), (Unknown, Database, Expired), (Unknown, Database, Resource), (Unknown, Database, PreviousFire), (Unknown, Database, TemplateLimit), (Unknown, Database, Merge), (Unknown, Database, Unknown), (Unknown, Database, AlreadyChanged), (Unknown, System, Truncate), (Unknown, System, Insert), (Unknown, System, Update), (Unknown, System, Delete), (Unknown, System, Drop), (Unknown, System, Alter), (Unknown, System, Restart), (Unknown, System, Error), (Unknown, System, Query), (Unknown, System, Invalid), (Unknown, System, Options), (Unknown, System, Isolation), (Unknown, System, Expired), (Unknown, System, Resource), (Unknown, System, PreviousFire), (Unknown, System, TemplateLimit), (Unknown, System, Merge), (Unknown, System, Unknown), (Unknown, System, AlreadyChanged), (Unknown, Statement, Truncate), (Unknown, Statement, Insert), (Unknown, Statement, Update), (Unknown, Statement, Delete), (Unknown, Statement, Drop), (Unknown, Statement, Alter), (Unknown, Statement, Restart), (Unknown, Statement, Error), (Unknown, Statement, Query), (Unknown, Statement, Invalid), (Unknown, Statement, Options), (Unknown, Statement, Isolation), (Unknown, Statement, Expired), (Unknown, Statement, Resource), (Unknown, Statement, PreviousFire), (Unknown, Statement, TemplateLimit), (Unknown, Statement, Merge), (Unknown, Statement, Unknown), (Unknown, Statement, AlreadyChanged), (Unknown, Environment, Truncate), (Unknown, Environment, Insert), (Unknown, Environment, Update), (Unknown, Environment, Delete), (Unknown, Environment, Drop), (Unknown, Environment, Alter), (Unknown, Environment, Restart), (Unknown, Environment, Error), (Unknown, Environment, Query), (Unknown, Environment, Invalid), (Unknown, Environment, Options), (Unknown, Environment, Isolation), (Unknown, Environment, Expired), (Unknown, Environment, Resource), (Unknown, Environment, PreviousFire), (Unknown, Environment, TemplateLimit), (Unknown, Environment, Merge), (Unknown, Environment, Unknown), (Unknown, Environment, AlreadyChanged), (Unknown, Execution, Truncate), (Unknown, Execution, Insert), (Unknown, Execution, Update), (Unknown, Execution, Delete), (Unknown, Execution, Drop), (Unknown, Execution, Alter), (Unknown, Execution, Restart), (Unknown, Execution, Error), (Unknown, Execution, Query), (Unknown, Execution, Invalid), (Unknown, Execution, Options), (Unknown, Execution, Isolation), (Unknown, Execution, Expired), (Unknown, Execution, Resource), (Unknown, Execution, PreviousFire), (Unknown, Execution, TemplateLimit), (Unknown, Execution, Merge), (Unknown, Execution, Unknown), (Unknown, Execution, AlreadyChanged), (Unknown, Owner, Truncate), (Unknown, Owner, Insert), (Unknown, Owner, Update), (Unknown, Owner, Delete), (Unknown, Owner, Drop), (Unknown, Owner, Alter), (Unknown, Owner, Restart), (Unknown, Owner, Error), (Unknown, Owner, Query), (Unknown, Owner, Invalid), (Unknown, Owner, Options), (Unknown, Owner, Isolation), (Unknown, Owner, Expired), (Unknown, Owner, Resource), (Unknown, Owner, PreviousFire), (Unknown, Owner, TemplateLimit), (Unknown, Owner, Merge), (Unknown, Owner, Unknown), (Unknown, Owner, AlreadyChanged), (Unknown, Unknown, Truncate), (Unknown, Unknown, Insert), (Unknown, Unknown, Update), (Unknown, Unknown, Delete), (Unknown, Unknown, Drop), (Unknown, Unknown, Alter), (Unknown, Unknown, Restart), (Unknown, Unknown, Error), (Unknown, Unknown, Query), (Unknown, Unknown, Invalid), (Unknown, Unknown, Options), (Unknown, Unknown, Isolation), (Unknown, Unknown, Expired), (Unknown, Unknown, Resource), (Unknown, Unknown, PreviousFire), (Unknown, Unknown, TemplateLimit), (Unknown, Unknown, Merge), (Unknown, Unknown, Unknown), (Unknown, Unknown, AlreadyChanged), (Unknown, Client, Truncate), (Unknown, Client, Insert), (Unknown, Client, Update), (Unknown, Client, Delete), (Unknown, Client, Drop), (Unknown, Client, Alter), (Unknown, Client, Restart), (Unknown, Client, Error), (Unknown, Client, Query), (Unknown, Client, Invalid), (Unknown, Client, Options), (Unknown, Client, Isolation), (Unknown, Client, Expired), (Unknown, Client, Resource), (Unknown, Client, PreviousFire), (Unknown, Client, TemplateLimit), (Unknown, Client, Merge), (Unknown, Client, Unknown), (Unknown, Client, AlreadyChanged)
Sources: SqlNotificationType Enumeration, SqlNotificationSource Enumeration, SqlNotificationInfo Enumeration and SqlNotificationType.cs, SqlNotificationInfo.cs, SqlNotificationSource.cs
精彩评论