code_junkie

How to determine whether SqlConnection is enlisted into a System.Transactions' tx or not?

Nov 11th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. public static bool IsEnlisted(SqlConnection con)
  2. {
  3. object o = typeof(SqlConnection).GetField("_innerConnection", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(con);
  4. o = o.GetType().GetField("_enlistedTransaction", BindingFlags.Instance | BindingFlags.NonPublic);
  5. return o != null;
  6. }
Add Comment
Please, Sign In to add comment