// Обработчик загрузки страницы protected void Page_Load(object sender, EventArgs e) { // Формируем список городов для просмотра // погодных данных CityList.Add(new City("Челябинск", 0)); CityList.Add(new City("Москва", 1)); CityList.Add(new City("Самара", 2)); // Формируем список погодных сервисов EntityConnectionStringBuilder ConnectionString = new EntityConnectionStringBuilder(); ConnectionString.ProviderConnectionString = @"data source=|DataDirectory|YahooWeatherDB.sqlite"; ConnectionString.Provider = @"System.Data.SQLite"; ConnectionString.Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl"; WeatherServiceList.Add(new WeatherService("Yahoo! Weather", ConnectionString.ToString())); ConnectionString.ProviderConnectionString = @"data source=|DataDirectory|YandexWeatherDB.sqlite"; WeatherServiceList.Add(new WeatherService("Яндекс Погода", ConnectionString.ToString())); // Привязываем список городов и погодных сервисов // к элементам интерфейса foreach (City item in CityList) if (!CityDropDownList.Items.Contains(new ListItem(item.Name))) CityDropDownList.Items.Add(new ListItem(item.Name)); foreach (var item in WeatherServiceList) if (!ServiceDropDownList.Items.Contains(new ListItem(item.Name))) ServiceDropDownList.Items.Add(new ListItem(item.Name)); }
public void WeatherBotTest() { // Строки подключения к БД List<string> cnctstrlist = new List<string>(); //Создаем подключение к БД и чистим таблицы БД EntityConnectionStringBuilder ConnectionString = new EntityConnectionStringBuilder(); ConnectionString.ProviderConnectionString = @"data source=../../Test_Data/WeatherBotTest/YahooWeatherDB.sqlite"; ConnectionString.Provider = @"System.Data.SQLite"; ConnectionString.Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl"; cnctstrlist.Add(ConnectionString.ToString()); LittleLogger logger = new LittleLogger("../../Test_Data/WeatherBotTest/log.txt"); WeatherWriter wWriter = new WeatherWriter(logger); wWriter.ClearData(ConnectionString.ToString()); ConnectionString.ProviderConnectionString = @"data source=../../Test_Data/WeatherBotTest/YandexWeatherDB.sqlite"; cnctstrlist.Add(ConnectionString.ToString()); wWriter.ClearData(ConnectionString.ToString()); // Формируем список городов для мониторинга // погодных данных List<City> CityList = new List<City>(); Dictionary<string, string> idlist = new Dictionary<string, string>(); // Челябинск idlist["Yahoo"] = "1997422"; idlist["Yandex"] = "28642"; City city1 = new City("Челябинск", idlist); CityList.Add(city1); // Москва idlist["Yahoo"] = "2122265"; idlist["Yandex"] = "27612"; City city2 = new City("Москва", idlist); CityList.Add(city2); // Самара idlist["Yahoo"] = "2077746"; idlist["Yandex"] = "28807"; City city3 = new City("Самара", idlist); CityList.Add(city3); // Интервал сбора погодных данных int timeout = 0; // Создаем погодного бота для одноразовго сбора погодных данных WeatherBot wBot = new WeatherBot(CityList, timeout, logger, cnctstrlist); wBot.Start(); }
/// <summary> /// Gets the entity framework connection string. /// </summary> /// <param name="contextType">Type of the context.</param> /// <param name="connectionString">The connection string.</param> /// <returns>The entity framework connection string.</returns> /// <exception cref="ArgumentNullException">The <paramref name="contextType"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">The <paramref name="connectionString" /> is <c>null</c> or whitespace.</exception> public static string GetEntityFrameworkConnectionString(Type contextType, string connectionString) { Argument.IsNotNull("contextType", contextType); Argument.IsNotNullOrWhitespace("connectionString", connectionString); if (connectionString.Contains("res://")) { // already EF connection string return connectionString; } var fullName = contextType.FullName; if (fullName.EndsWith("Container")) { fullName = fullName.Substring(0, fullName.Length - "Container".Length); } var assemblyNameParts = contextType.Assembly.GetName().Name.Split(new[] { '.' }); foreach (var assemblyNamePart in assemblyNameParts) { string itemToReplace = string.Format("{0}.", assemblyNamePart); if (fullName.StartsWith(itemToReplace)) { fullName = fullName.Remove(0, itemToReplace.Length); } } var connectionBuilder = new EntityConnectionStringBuilder(); connectionBuilder.Provider = "System.Data.SqlClient"; connectionBuilder.Metadata = string.Format("res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl", fullName); connectionBuilder.ProviderConnectionString = connectionString; return connectionBuilder.ToString(); }
public HERBProject_DataBaseEntities GetEntitiesContext() { // Initialize Entity Connection String Builder EntityConnectionStringBuilder entityConnectionStringBuilder = new EntityConnectionStringBuilder(); // Set the provider name entityConnectionStringBuilder.Provider = "System.Data.SqlClient"; // Set the provider-specific connection string entityConnectionStringBuilder.ProviderConnectionString = _connectionString; entityConnectionStringBuilder.ProviderConnectionString += ";MultipleActiveResultSets=True"; // Set the Metadata location entityConnectionStringBuilder.Metadata = string.Format("{0}|{1}|{2}", "res://*/Repositories.CustomBoundedRepository.HERBProject_DataBase.csdl", "res://*/Repositories.CustomBoundedRepository.HERBProject_DataBase.ssdl", "res://*/Repositories.CustomBoundedRepository.HERBProject_DataBase.msl"); // Build Entity Connection EntityConnection entityConnection = new EntityConnection(entityConnectionStringBuilder.ToString()); // Initialize Entity Object return new HERBProject_DataBaseEntities(entityConnection) { CommandTimeout = _commandTimeOut }; }
/// <summary> /// Retrieves and builds an entity connection string given one specified in web.config. /// </summary> /// <returns>Connection String for a store that is intended to host tokens.</returns> internal static string GetEntityConnectionString() { string cs = string.Empty; System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot"); System.Configuration.ConnectionStringSettings connString; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { connString = rootWebConfig.ConnectionStrings.ConnectionStrings["AppTokenStorage"]; if (connString != null) { cs = connString.ConnectionString; } else { throw new Exception("No connection string named 'AppTokenStorage' was declared in web.config."); } } EntityConnectionStringBuilder ecsb = new EntityConnectionStringBuilder(); ecsb.ProviderConnectionString = cs + ";MultipleActiveResultSets=True;Application Name=EntityFramework"; ecsb.Provider = "System.Data.SqlClient"; ecsb.Metadata = "res://*/TokenStore.csdl|res://*/TokenStore.ssdl|res://*/TokenStore.msl"; return ecsb.ToString(); }
public DBConnection() { // Specify the provider name, server and database. // Initialize the connection string builder for the // underlying provider. SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); // Set the properties for the data source. sqlBuilder.DataSource = serverName; sqlBuilder.InitialCatalog = databaseName; sqlBuilder.IntegratedSecurity = true; // Build the SqlConnection connection string. string providerString = sqlBuilder.ToString(); // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); //Set the provider name. entityBuilder.Provider = providerName; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = providerString; // Set the Metadata location. entityBuilder.Metadata =@"res://*/ShoeShopEntity.csdl|res://*/ShoeShopEntity.ssdl|res://*/ShoeShopEntity.msl"; entity = new SHOESHOPEntities(entityBuilder.ToString()); }
protected override string CreateConnectionString() { // Specify the provider name, server and database. string providerName = "System.Data.SqlClient"; string serverName = ".\\SQLEXPRESS"; string databaseName = "ZMTdb"; // Initialize the connection string builder for the // underlying provider. SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); // Set the properties for the data source. sqlBuilder.DataSource = serverName; sqlBuilder.InitialCatalog = databaseName; sqlBuilder.IntegratedSecurity = true; // Build the SqlConnection connection string. string providerString = sqlBuilder.ToString(); // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); //Set the provider name. entityBuilder.Provider = providerName; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = providerString; // Set the Metadata location. entityBuilder.Metadata = @"res://EF_ZMTdbConnection/EF_ZMTdbModel.csdl|res://EF_ZMTdbConnection/EF_ZMTdbModel.ssdl|res://EF_ZMTdbConnection/EF_ZMTdbModel.msl"; return entityBuilder.ToString(); }
// Метод для асинхронного создания подключения к БД private async Task<bool> DbConnectAsync(string dbname) { try { // Создаем строку подключения EntityConnectionStringBuilder ConnectionString = new EntityConnectionStringBuilder(); ConnectionString.ProviderConnectionString = "data source=" + Uchet.Properties.Settings.Default.dbDir + dbname; ConnectionString.Provider = Uchet.Properties.Settings.Default.dbProvider; ConnectionString.Metadata = @Uchet.Properties.Settings.Default.dbMetadata; // Асинхронно создаем подключение await Task.Run(() => { this.DB = new DBEntity(ConnectionString.ToString()); // Задаем DataSource для таблиц в соответствии с таблицами БД приложения this.Invoke((Action)delegate{ gearCountEntityBindingSource.DataSource = DB.GC.ToList<GearCountEntity>(); gearCountEntityBindingSource.DataSource = DB.GC.Local.ToBindingList<GearCountEntity>(); gearPriceEntityBindingSource.DataSource = DB.GP.ToList<GearPriceEntity>(); gearSumEntityBindingSource.DataSource = DB.GS.ToList<GearSumEntity>(); gearSumEntityBindingSource.DataSource = DB.GS.Local.ToBindingList<GearSumEntity>(); }); }); return true; } catch (Exception exeption) { MessageBox.Show(exeption.Message, "Ошибка!"); } return false; }
public static string CreateInstance(string filePrefix, string connectionString) { System.Data.EntityClient.EntityConnectionStringBuilder csb = new System.Data.EntityClient.EntityConnectionStringBuilder(); csb.Metadata = "res://*/" + filePrefix + ".csdl|res://*/" + filePrefix + ".ssdl|res://*/" + filePrefix + ".msl"; csb.Provider = "Npgsql"; csb.ProviderConnectionString = connectionString; return(csb.ToString()); }
/// <summary> /// Gets the DB connection /// connection parameters are decrypted /// </summary> /// <returns>An Entity (Framework) connection</returns> public static EntityConnection GetEntityConnection(string serverURI) { EntityConnection ans = null; EntityConnection conn = null; try { // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); // Set the provider name. entityBuilder.Provider = "MySql.Data.MySqlClient"; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = GetSqlBuilder(serverURI).ToString(); // Set the Metadata location. entityBuilder.Metadata = @"res://*/Entities.BourseEntities.csdl|res://*/Entities.BourseEntities.ssdl|res://*/Entities.BourseEntities.msl"; string st = entityBuilder.ToString(); conn = new EntityConnection(entityBuilder.ToString()); conn.Open(); // Just testing the connection. conn.Close(); // CA2000 prevention ans = conn; conn = null; return ans; } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } }
public static string LocalMachine(string databaseName) { var entityBuilder = new EntityConnectionStringBuilder(); entityBuilder.Provider = "System.Data.SqlClient"; entityBuilder.ProviderConnectionString = string.Format("data source=.;initial catalog={0};persist security info=True;user id=sa;password=d3hPOTraPC;multipleactiveresultsets=True;App={0}", databaseName); entityBuilder.Metadata = "res://*/Domain.csdl|res://*/Domain.ssdl|res://*/Domain.msl"; return entityBuilder.ToString(); }
public string SetEntityConnection(string serverName, string initInstanceName) { EntityConnectionStringBuilder enityBuilder = new EntityConnectionStringBuilder(); enityBuilder.Provider = "System.Data.SqlClient"; enityBuilder.Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl"; enityBuilder.ProviderConnectionString = "Data Source=" + serverName + "\\" + initInstanceName + ";Initial Catalog=ozyrys;Integrated Security=SSPI;multipleactiveresultsets=True;App=EntityFramework"; sqlConn = enityBuilder.ToString(); return sqlConn; }
public void DBReadWriteTest_1() { // Подключаемся к БД EntityConnectionStringBuilder ConnectionString = new EntityConnectionStringBuilder(); ConnectionString.ProviderConnectionString = @"data source=../../Test_Data/DBReadWriteTest_1/testDB.sqlite"; ConnectionString.Provider = @"System.Data.SQLite"; ConnectionString.Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl"; WeatherDBEntity testDB = new WeatherDBEntity(ConnectionString.ToString()); // Очистка таблиц БД foreach (var item in testDB.City1Entity) testDB.City1Entity.Remove(item); foreach (var item in testDB.City2Entity) testDB.City2Entity.Remove(item); foreach (var item in testDB.City3Entity) testDB.City3Entity.Remove(item); // Сохраняем состояние БД testDB.SaveChanges(); // Создаем записи в таблицы БД // Запись в таблицу 1-ого города City1Entity City1Item = new City1Entity(); City1Item.Date = "29.06.2014"; City1Item.Temperature = "24"; City1Item.Pressure = "748"; City1Item.Wetness = "28"; City1Item.Wind = "с/з 10"; City1Item.Clouds = "Облачно"; testDB.City1Entity.Add(City1Item); // Запись в таблицу 2-ого города City2Entity City2Item = new City2Entity(); City2Item.Date = "30.07.2015"; City2Item.Temperature = "26"; City2Item.Pressure = "749"; City2Item.Wetness = "30"; City2Item.Wind = "с/в 3"; City2Item.Clouds = "Ясно"; testDB.City2Entity.Add(City2Item); // Запись в таблицу 3-ого города City3Entity City3Item = new City3Entity(); City3Item.Date = "05.03.2014"; City3Item.Temperature = "30"; City3Item.Pressure = "750"; City3Item.Wetness = "20"; City3Item.Wind = "ю/в 5"; City3Item.Clouds = "Пасмурно"; testDB.City3Entity.Add(City3Item); // Сохраняем состояние БД testDB.SaveChanges(); // Читаем записи из таблиц БД и сравниваем с ожидаемым результатом Assert.AreEqual<City1Entity>(City1Item, testDB.City1Entity.ToList<City1Entity>()[0]); Assert.AreEqual<City2Entity>(City2Item, testDB.City2Entity.ToList<City2Entity>()[0]); Assert.AreEqual<City3Entity>(City3Item, testDB.City3Entity.ToList<City3Entity>()[0]); }
public static string GetConnectionString() { string baseConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; var entityBuilder = new EntityConnectionStringBuilder(); entityBuilder.Provider = "System.Data.SqlClient"; entityBuilder.ProviderConnectionString = baseConnectionString; entityBuilder.Metadata = @"res://*/SceneCRM.csdl|res://*/SceneCRM.ssdl|res://*/SceneCRM.msl"; return entityBuilder.ToString(); }
public static string GetConnectionStringEF() { EntityConnectionStringBuilder entityConnectionString = new EntityConnectionStringBuilder(); SqlConnectionStringBuilder sqlConnectionStringBuilder = new SqlConnectionStringBuilder("data source=localhost;initial catalog=MyBlog;persist security info=True;user id=sa;password=andheri788;MultipleActiveResultSets=True;App=EntityFramework"); entityConnectionString.ProviderConnectionString = sqlConnectionStringBuilder.ToString(); entityConnectionString.Metadata = "res://*/MyBlog.csdl|res://*/MyBlog.ssdl|res://*/MyBlog.msl"; entityConnectionString.Provider = "System.Data.SqlClient"; return entityConnectionString.ToString(); }
public static DNNAwesomeEntities Instance() { var entityBuilder = new System.Data.EntityClient.EntityConnectionStringBuilder(); entityBuilder.ProviderConnectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString(); entityBuilder.Metadata = "res://*/"; entityBuilder.Provider = "System.Data.SqlClient"; return(new DNNAwesomeEntities(entityBuilder.ToString())); }
/// <summary> /// Creates the connection string. /// </summary> /// <param name="assembly">The assembly.</param> /// <param name="model">The model.</param> /// <param name="sqlConnectionString">The SQL connection string.</param> /// <returns></returns> public static EntityConnection CreateConnectionString(Assembly assembly, string model, string sqlConnectionString) { var entityconnectionBuilder = new EntityConnectionStringBuilder { Provider = "System.Data.SqlClient", ProviderConnectionString = sqlConnectionString, Metadata = string.Format("res://{0}/{1}.csdl|res://{0}/{1}.ssdl|res://{0}/{1}.msl", assembly.GetName().Name, model) }; return new EntityConnection(entityconnectionBuilder.ToString()); }
/// <summary> /// Gets a connection string /// </summary> /// <returns>Connection string</returns> public static string GetEntityConnectionString() { if (_connectionString == null) { var ecsbuilder = new EntityConnectionStringBuilder(); ecsbuilder.Provider = "System.Data.SqlClient"; ecsbuilder.ProviderConnectionString = NopConfig.ConnectionString; ecsbuilder.Metadata = @"res://*/Data.NopModel.csdl|res://*/Data.NopModel.ssdl|res://*/Data.NopModel.msl"; _connectionString = ecsbuilder.ToString(); } return _connectionString; }
protected override string GetEntitiesConnectionString() { var builder = new EntityConnectionStringBuilder { ProviderConnectionString = GetConnectionString(), Provider = "System.Data.SqlClient", Metadata = "res://AboutPocoHandling/AboutPocoHandling.csdl" + "|res://AboutPocoHandling/AboutPocoHandling.ssdl" + "|res://AboutPocoHandling/AboutPocoHandling.msl" }; return builder.ToString(); }
/// <summary> /// Gets a connection string /// </summary> /// <returns>Connection string</returns> public static string GetEntityConnectionString() { if (_connectionString == null) { var ecsbuilder = new EntityConnectionStringBuilder(); ecsbuilder.Provider = "System.Data.SqlClient"; ecsbuilder.ProviderConnectionString = ConfigurationManager.ConnectionStrings["CornerSiteConnectionString"].ToString(); //ecsbuilder.Metadata = @"res://*/Data.NopModel.csdl|res://*/Data.NopModel.ssdl|res://*/Data.NopModel.msl"; ecsbuilder.Metadata = @"res://*/Data.Data.csdl|res://*/Data.Data.ssdl|res://*/Data.Data.msl"; _connectionString = ecsbuilder.ToString(); } return _connectionString; }
public void ReadFromDBTest_2() { // Формируем объекты класса WeatherService EntityConnectionStringBuilder ConnectionString = new EntityConnectionStringBuilder(); ConnectionString.ProviderConnectionString = @"data source=../../Test_Data/ReadFromDBTest_2/YahooWeatherDB.sqlite"; ConnectionString.Provider = @"System.Data.SQLite"; ConnectionString.Metadata = @"res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl"; WeatherService wService1 = new WeatherService("Yahoo", ConnectionString.ToString()); ConnectionString.ProviderConnectionString = @"data source=../../Test_Data/ReadFromDBTest_2/YandexWeatherDB.sqlite"; WeatherService wService2 = new WeatherService("Yandex", ConnectionString.ToString()); // Параметр даты для запроса к БД LittleLogger logger = new LittleLogger("../../Test_Data/ReadFromDBTest_2/log.txt"); DateString dateStr = new DateString(logger); string date1 = dateStr.GetYahooDate("05.06.2014"); string date2 = dateStr.GetYandexDate("05.06.2014"); // Запрос погодных данных за 05.06.2014 Forecaster forecaster = new Forecaster(logger); List<City1Entity> weather1_1 = forecaster.GetCity1Weather(wService1, date1); List<City2Entity> weather1_2 = forecaster.GetCity2Weather(wService1, date1); List<City3Entity> weather1_3 = forecaster.GetCity3Weather(wService1, date1); List<City1Entity> weather2_1 = forecaster.GetCity1Weather(wService2, date2); List<City2Entity> weather2_2 = forecaster.GetCity2Weather(wService2, date2); List<City3Entity> weather2_3 = forecaster.GetCity3Weather(wService2, date2); // Сравниваем ожидаемые и фактические значения Assert.AreEqual(5, weather1_1.Count); Assert.AreEqual(3, weather1_2.Count); Assert.AreEqual(4, weather1_3.Count); Assert.AreEqual(10, weather2_1.Count); Assert.AreEqual(9, weather2_2.Count); Assert.AreEqual(8, weather2_3.Count); }
public static string CreateEntityString(EntitySetting setting) { // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); //Set the provider name. entityBuilder.Provider = "System.Data.SqlClient"; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = CreateConnectionString(setting); // Set the Metadata location. entityBuilder.Metadata = setting.Metadata; return entityBuilder.ToString(); }
public ConnectionProvider() { var entityConnectionStringBuilder = new EntityConnectionStringBuilder { Provider = "Oracle.DataAccess.Client", ProviderConnectionString = "DATA SOURCE=localhost:1521/xe;PASSWORD={1};PERSIST SECURITY INFO=True;USER ID={0}", Metadata = "res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl" }; _connectionStringFormat = entityConnectionStringBuilder.ToString(); }
public static SIST_SUPERMERCADOEntities ObtenerInstancia() { ArchivoBaseDeDatos(); // Specify the provider name, server and database. string providerName = "System.Data.SqlClient"; // Initialize the connection string builder for the // underlying provider. SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); // Set the properties for the data source. sqlBuilder.DataSource = serverName; sqlBuilder.InitialCatalog = databaseName; sqlBuilder.UserID = UserID; sqlBuilder.Password = Password; sqlBuilder.IntegratedSecurity = false; sqlBuilder.MultipleActiveResultSets = true; sqlBuilder.UserInstance = false; // Build the SqlConnection connection string. string providerString = sqlBuilder.ToString(); // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); //Set the provider name. entityBuilder.Provider = providerName; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = providerString; // Set the Metadata location. SIST_SUPERMERCADO entityBuilder.Metadata = @"res://*/" + Contexto + ".csdl|res://*/" + Contexto + ".ssdl|res://*/" + Contexto + ".msl"; EntityConnection conn = new EntityConnection(entityBuilder.ToString()); _instancia = new SIST_SUPERMERCADOEntities(conn); StringConexion = entityBuilder.ProviderConnectionString; return _instancia; }
private QDBData() { SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); sqlBuilder.DataSource = @"BLR-L-CSNAVEEN\test"; sqlBuilder.InitialCatalog = "QDB"; sqlBuilder.UserID = "mobileadmin"; sqlBuilder.Password = "******"; sqlBuilder.MultipleActiveResultSets = true; EntityConnectionStringBuilder connBuilder = new EntityConnectionStringBuilder(); connBuilder.Provider = "System.Data.SqlClient"; connBuilder.ProviderConnectionString = sqlBuilder.ToString(); connBuilder.Metadata = @"res://*/QDBEntities.csdl|res://*/QDBEntities.ssdl|res://*/QDBEntities.msl"; EntityConnection connection = new EntityConnection(connBuilder.ToString()); context = new QDBEntities(connection); }
static DictionaryEntities InitializeThreadProc() { string providerString = "Data Source=Dictionary.sdf"; string providerName = "System.Data.SqlServerCe.3.5"; // Initialize the EntityConnectionStringBuilder. EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); entityBuilder.Provider = providerName; entityBuilder.ProviderConnectionString = providerString; entityBuilder.Metadata = @"Res://ER/"; var connection = new EntityConnection(entityBuilder.ToString()); connection.Open(); var entities = new DictionaryEntities(connection); return entities; }
public PlowMachineManager() { #region Контекст подкючения к БД string connectionString = DBConnectionHelper.GetConnectionString(); EntityConnectionStringBuilder bldr = new EntityConnectionStringBuilder(); bldr.Metadata = ENTITY_METADATA; bldr.ProviderConnectionString = connectionString; bldr.Provider = "System.Data.SqlClient"; EntityConnection connection = new EntityConnection(bldr.ToString()); _context = new PlowMachineEntities(bldr.ConnectionString); #endregion _moduleManager = new ModuleManager(); }
private string GetConnectionString() { SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); sqlBuilder.MaxPoolSize = Properties.Settings.Default.MaxPoolSize; sqlBuilder.Pooling = Properties.Settings.Default.Pooling; sqlBuilder.UserID = Properties.Settings.Default.UserID; sqlBuilder.DataSource = Properties.Settings.Default.DataSource; sqlBuilder.Password = Properties.Settings.Default.Password; string ProviderString = sqlBuilder.ToString(); EntityConnectionStringBuilder entBuilder = new EntityConnectionStringBuilder(); entBuilder.Provider = "Devart.Data.Oracle"; entBuilder.ProviderConnectionString = ProviderString; entBuilder.Metadata = @"res://*/emSyncServices.csdl| res://*/emSyncServices.ssdl| res://*/emSyncServices.msl"; return entBuilder.ToString(); }
private string GetConnectionString(string branch) { SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder(); sqlBuilder.MaxPoolSize = 100; sqlBuilder.Pooling = false; sqlBuilder.UserID = "distrdev"; sqlBuilder.DataSource = branch; sqlBuilder.Password = "******"; string ProviderString = sqlBuilder.ToString(); EntityConnectionStringBuilder entBuilder = new EntityConnectionStringBuilder(); entBuilder.Provider = "Devart.Data.Oracle"; entBuilder.ProviderConnectionString = ProviderString; entBuilder.Metadata = @"res://*/emSyncServices.csdl| res://*/emSyncServices.ssdl| res://*/emSyncServices.msl"; return entBuilder.ToString(); }
public string BuildConnectionString() { ShellSettings shellSettings = LoadSettings().FirstOrDefault(); string providerName = "System.Data.SqlClient"; string connectionString = shellSettings.DataConnectionString; var entityBuilder = new EntityConnectionStringBuilder(); //Set the provider name. entityBuilder.Provider = providerName; // Set the provider-specific connection string. entityBuilder.ProviderConnectionString = connectionString; // Set the Metadata location. entityBuilder.Metadata = "res://*/Model.LiveoModel.csdl|res://*/Model.LiveoModel.ssdl|res://*/Model.LiveoModel.msl"; return entityBuilder.ToString(); }
public AspNetObjectContextManager(string connectionString) { if (!System.Web.HttpContext.Current.Items.Contains("ObjectContext")) { // build the connection string EntityConnectionStringBuilder entityConnectionStringBuilder = new EntityConnectionStringBuilder(); entityConnectionStringBuilder.ConnectionString = connectionString; entityConnectionStringBuilder.Metadata = @"res://*/NorthwindDB.csdl|res://*/NorthwindDB.ssdl|res://*/NorthwindDB.msl"; ObjectContext objectContext = new ObjectContext( new EntityConnection(entityConnectionStringBuilder.ToString())); System.Web.HttpContext.Current.Items. Add("ObjectContext", objectContext); } }
protected static string GetEntityConnString(ConnectionStringSettings connsetting) { if (connMap.ContainsKey(connsetting)) { return connMap[connsetting]; } var entityBuilder = new EntityConnectionStringBuilder { Metadata = string.Format( "res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl", connsetting.Name), ProviderConnectionString = connsetting.ConnectionString, Provider = connsetting.ProviderName }; var connstr = entityBuilder.ToString(); connMap.Add(connsetting, connstr); return connstr; }