Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
Copy Source | Copy HTML public static class CachingHelper { /// <summary> /// /// </summary> private static string conString = System.Configuration.ConfigurationManager. ConnectionStrings [ "pltfrmDBConnectionString" ].ConnectionString; /// <summary> /// Cache instance object /// </summary> private static volatile Cache cache = HttpContext.Current.Cache; /// <summary> /// Object for proper locking of cache additions/removals /// </summary> private static object syncRoot = new object (); /// <summary> /// /// </summary> /// <param name="query"> </param> /// <typeparam name="T"> </typeparam> /// <returns> T</returns> public static T [] LinqCache< T >( this Table< T > query) where T : class { var tableName = query.Context.Mapping.GetTable( typeof ( T )).TableName; var result = cache[tableName] as T []; if (result != null ) { return result; } var trop = new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }; var req = TransactionScopeOption.Required; if (Transaction.Current == null || Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted) { req = TransactionScopeOption.RequiresNew; } using ( var ts = new TransactionScope (req, trop)) { using ( var cn = new SqlConnection (conString)) { try { cn.Open(); var cmdText = query.Context.GetCommand(query).CommandText; var cmd = new SqlCommand (cmdText, cn) { NotificationAutoEnlist = true , Notification = null , CommandType = CommandType.Text }; foreach ( DbParameter dbp in query.Context.GetCommand(query).Parameters) { cmd.Parameters.Add( new SqlParameter (dbp.ParameterName, dbp.Value)); } var dependency = new SqlCacheDependency (cmd); cmd.ExecuteNonQuery(); result = query.ToArray(); cache.Insert(tableName, result, dependency); } catch (SqlException e) { if (e.Number == 4060 ) { throw new AuthenticationException ( " " ); } throw ; } } ts.Complete(); } return result; } }
使用方法は、梨を砲撃するのと同じくらい簡単です。
1)Global.asaxに追加
Copy Source | Copy HTML
- /// <summary>
- ///アプリケーション開始イベント
- /// </ summary>
- /// <param name = "sender">
- ///呼び出し元
- /// </ param>
- /// <param name = "e">
- ///イベント引数
- /// </ param>
- protected void Application_Start( オブジェクト送信者、 EventArgs e)
- {
- SqlDependency.Start(ConfigurationManager.ConnectionStrings [ "pltfrmDBConnectionString" ] .ConnectionString);
- }
- /// <summary>
- ///アプリケーション終了イベント
- /// </ summary>
- /// <param name = "sender">
- ///呼び出し元
- /// </ param>
- /// <param name = "e">
- ///イベント引数
- /// </ param>
- protected void Application_End( オブジェクト送信者、 EventArgs e)
- {
- SqlDependency.Stop(ConfigurationManager.ConnectionStrings [ "pltfrmDBConnectionString" ] .ConnectionString);
- }
2)アプリケーションでの使用:
Copy Source | Copy HTML
- var db = new SomeContext ();
- var cached = db.SomeTable.LinqCache()。Where(a => ab == "qwe" );
PSこの方法が機能するには、SQLサーバーブローカーが有効になっている必要があります
PPSトランザクションはオプションです;これらは現在のプロジェクトからのコードの一部です:)