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; } }
Copy Source | Copy HTML
- /// <summary>
- /// Application start event
- /// </ summary>
- /// <param name = "sender">
- /// caller
- /// </ param>
- /// <param name = "e">
- /// Event Arguments
- /// </ param>
- protected void Application_Start ( object sender, EventArgs e)
- {
- SqlDependency.Start (ConfigurationManager.ConnectionStrings [ "pltfrmDBConnectionString" ] .ConnectionString);
- }
- /// <summary>
- /// Application termination event
- /// </ summary>
- /// <param name = "sender">
- /// caller
- /// </ param>
- /// <param name = "e">
- /// Event Arguments
- /// </ param>
- protected void Application_End ( object sender, EventArgs e)
- {
- SqlDependency.Stop (ConfigurationManager.ConnectionStrings [ "pltfrmDBConnectionString" ] .ConnectionString);
- }
Copy Source | Copy HTML
- var db = new SomeContext ();
- var cached = db.SomeTable.LinqCache (). Where (a => ab == "qwe" );
Source: https://habr.com/ru/post/61655/
All Articles