private string GetConnectionString() { var connectionInfo = GetParametersForConnectionString(); var connectionStringBuilder = new ConnectionStringBuilder(connectionInfo); return(connectionStringBuilder.GetConnectionString(GuiConfiguration.DatabaseProvider.InvariantName)); }
public void TestGetConnectionString() { TestSetConnectionString(); ConnectionStringBuilder builder = ConnectionStringBuilder.getInstance(); Assert.Equal(builder.GetConnectionString(), _connectionString); }
public async Task <ActionResult <IEnumerable <string> > > Get([FromQuery] string country) { var cs = await csb.GetConnectionString(); using (var connection = new SqlConnection(cs)) { await connection.OpenAsync(); using (var cmd = connection.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT 'Foo' AS CustomerName WHERE @Country = '' OR 'AT' = @Country UNION ALL SELECT 'Bar'"; cmd.Parameters.AddWithValue("@Country", string.IsNullOrEmpty(country) ? string.Empty : country); using (var reader = await cmd.ExecuteReaderAsync()) { var result = new List <string>(); var customerNameOrdinal = reader.GetOrdinal("CustomerName"); while (await reader.ReadAsync()) { result.Add(reader.GetString(customerNameOrdinal)); } return(result); } } } }
private static GlobalContext OpenContext(string databaseFullPath) { ProcessesHelpers.KillOwnProcessesByName("1cv8.exe"); var connectionStringBuilder = new ConnectionStringBuilder { Type = Connection1CType.File, FileLocation = databaseFullPath, User = "******", Password = "" }; var globalContextFactory = new GlobalContextFactory(); var globalContextComObject = globalContextFactory.Create(connectionStringBuilder.GetConnectionString()); return(new GlobalContext(globalContextComObject)); }
public ApplicationDbContext() : base(ConnectionStringBuilder.GetConnectionString()) { Database.SetInitializer <ApplicationDbContext>(new DbInitializer()); }