BolfTracker.Infrastructure.EntityFramework.BolfTrackerDbConnection.GetProfiledConnection C# (CSharp) Method

GetProfiledConnection() public static method

public static GetProfiledConnection ( ) : DbConnection
return System.Data.Common.DbConnection
        public static DbConnection GetProfiledConnection()
        {
            var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["BolfTracker"].ConnectionString);

            // Wrap the connection with a profiling connection that tracks timings
            return new StackExchange.Profiling.Data.ProfiledDbConnection(connection, StackExchange.Profiling.MiniProfiler.Current);
        }

Usage Example

 public void DeleteByMonthAndYear(int month, int year)
 {
     using (var connection = BolfTrackerDbConnection.GetProfiledConnection())
     {
         connection.Open();
         string command = "DELETE PlayerRivalryStatistics FROM PlayerRivalryStatistics prs INNER JOIN Game g ON g.Id = prs.GameId WHERE (DATEPART (month, g.[Date])) = @Month AND (DATEPART (year, g.[Date])) = @Year";
         connection.Execute(command, new { Month = month, Year = year });
     }
 }
All Usage Examples Of BolfTracker.Infrastructure.EntityFramework.BolfTrackerDbConnection::GetProfiledConnection
BolfTrackerDbConnection