public IDbConnection CreateDbConnection() { IDbConnection connection = null; switch (databaseType) { case "sqlserver": var cnn = new System.Data.SqlClient.SqlConnection(connectionString); connection = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current); //connection = new System.Data.SqlClient.SqlConnection(connectionString); break; case "mysql": //connection = new MySql.Data.MySqlClient.MySqlConnection(connectionString); break; case "oracle": //connection = new Oracle.DataAccess.Client.OracleConnection(connectionString); //connection = new System.Data.OracleClient.OracleConnection(connectionString); break; case "db2": //connection = new System.Data.OleDb.OleDbConnection(connectionString); break; default: connection = new System.Data.SqlClient.SqlConnection(connectionString); break; } return(connection); }
public static AppUser GetUser(string username) { DbConnection cnn = new SqlConnection(Application.HRConnectionString); AppUser user = null; #if !DEBUG try { if (Current.Profiler != null) cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, new ErrorLoggingProfiler(Current.Profiler)); cnn.Open(); user = cnn.Query<User>("select * from Users where Username=@Username", new { username }).FirstOrDefault(); } finally { if (cnn != null) { cnn.Dispose(); } } #else user = new AppUser() { Username = username, FullName = "พิฐากูร สุวรรณเนกข์", Department = "ศรัทธาภิบาล", Section = "ธรรมวารี", MemberType = "อาสาสมัคร" }; #endif return user; }
public static IntiDataContext GetConnection() { var connection = new StackExchange.Profiling.Data.ProfiledDbConnection(new SqlConnection(ConnectionString), MiniProfiler.Current); return(new IntiDataContext(connection)); }
/// <summary> /// Answers a new DBContext for the current site. /// </summary> public static ValentinesDataContext GetContext() { var cnnString = ConfigurationManager.ConnectionStrings["valentinesConnectionString"].ConnectionString; var conn = new StackExchange.Profiling.Data.ProfiledDbConnection(new SqlConnection(cnnString), MiniProfiler.Current); return(new ValentinesDataContext(conn)); }
public static IDbConnection CreateConnection() { DbConnection dbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["JourneyDiary"].ConnectionString); if (bool.Parse(ConfigurationManager.AppSettings["OpenMiniProfiler"])) { dbConnection = new StackExchange.Profiling.Data.ProfiledDbConnection(dbConnection, MiniProfiler.Current); } return(dbConnection); }
/// <summary> /// Returns an open connection that will have its queries profiled. /// </summary> /// <returns>the database connection abstraction</returns> public static DbConnection GetConnection() { DbConnection cnn = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:"); // to get profiling times, we have to wrap whatever connection we're using in a ProfiledDbConnection // when MiniProfiler.Current is null, this connection will not record any database timings if (MiniProfiler.Current != null) { cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current); } cnn.Open(); return(cnn); }
/// <summary> /// Returns an open connection that will have its queries profiled. /// </summary> /// <returns>the database connection abstraction</returns> public static DbConnection GetConnection() { DbConnection cnn = new System.Data.SQLite.SQLiteConnection("Data Source=:memory:"); // to get profiling times, we have to wrap whatever connection we're using in a ProfiledDbConnection // when MiniProfiler.Current is null, this connection will not record any database timings if (MiniProfiler.Current != null) { cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current); } cnn.Open(); return cnn; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddMiniProfiler(options => options.RouteBasePath = "/profiler"); services.AddTransient <IRepository>(ctx => { string connectionString = @"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=InsideTSQL2008;Data Source=AFRBX;"; DbConnection connection = new SqlConnection(connectionString); var con = new StackExchange.Profiling.Data.ProfiledDbConnection(connection, MiniProfiler.Current); return(new Repository(con)); }); services.AddControllers(); }
public IDbConnection CreateOpenConnection() { MiniProfiler mp = new MiniProfiler($"{Assembly.GetEntryAssembly()?.GetName()} - DatabaseUpdater", MiniProfiler.DefaultOptions); (output ?? (output = new NullOutput())).MiniProfiler = mp; var connection = new StackExchange.Profiling.Data.ProfiledDbConnection(CreteConnection(), mp); connection.Disposed += (_, __) => { mp.Stop(); }; using (mp?.Ignore()) { connection.Open(); } return(connection); }
/// <summary> /// Returns an open connection that will have its queries profiled. /// </summary> /// <param name="profiler">The mini profiler.</param> /// <returns>the data connection abstraction.</returns> public static DbConnection GetConnection(MiniProfiler profiler = null) { using (profiler.Step("GetOpenConnection")) { DbConnection cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.SQLiteConnectionString); // to get profiling times, we have to wrap whatever connection we're using in a ProfiledDbConnection // when MiniProfiler.Current is null, this connection will not record any database timings if (MiniProfiler.Current != null) { cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current); } cnn.Open(); return(cnn); } }
public static DbConnection GetConnection(MiniProfiler profiler = null) { using (profiler.Step("GetOpenConnection")) { DbConnection cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.ConnectionString); // to get profiling times, we have to wrap whatever connection we're using in a ProfiledDbConnection // when MiniProfiler.Current is null, this connection will not record any database timings if (MiniProfiler.Current != null) { cnn = new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current); } cnn.Open(); return cnn; } }
/// <summary> /// Answers a new DBContext for the current site. /// </summary> public static ValentinesDataContext GetContext() { var cnnString = ConfigurationManager.ConnectionStrings["valentinesConnectionString"].ConnectionString; var conn = new StackExchange.Profiling.Data.ProfiledDbConnection(new SqlConnection(cnnString), MiniProfiler.Current); return new ValentinesDataContext(conn); }
public static IntiDataContext GetConnection() { var connection = new StackExchange.Profiling.Data.ProfiledDbConnection(new SqlConnection(ConnectionString), MiniProfiler.Current); return new IntiDataContext(connection); }