Ejemplo n.º 1
0
        internal static string ConvertNormalCS2EFFromConfig(string configSettings, DatabasePlatformConstants platform)
        {
            if (string.IsNullOrEmpty(configSettings))
            {
                return(configSettings);
            }
            var arr = configSettings.Split('=');

            if (arr.Length != 2)
            {
                return(configSettings);
            }
            if (arr[0] != "name")
            {
                return(configSettings);
            }
            try
            {
                var cs = System.Configuration.ConfigurationManager.ConnectionStrings[arr[1]].ConnectionString;
                if (!cs.StartsWith("metadata="))
                {
                    return(ConvertNormalCS2EF(cs, platform));
                }
                return(configSettings);
            }
            catch
            {
                return(configSettings);
            }
        }
Ejemplo n.º 2
0
		internal static string ConvertNormalCS2EFFromConfig(string configSettings, DatabasePlatformConstants platform)
		{
			if (string.IsNullOrEmpty(configSettings)) return configSettings;
			var arr = configSettings.Split('=');
			if (arr.Length != 2) return configSettings;
			if (arr[0] != "name") return configSettings;
			try
			{
				var cs = System.Configuration.ConfigurationManager.ConnectionStrings[arr[1]].ConnectionString;
				if (!cs.StartsWith("metadata=")) return ConvertNormalCS2EF(cs, platform);
				return configSettings;
			}
			catch
			{
				return configSettings;
			}
		}
Ejemplo n.º 3
0
        internal static string ConvertNormalCS2EF(string connectionString, DatabasePlatformConstants platform)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                return(connectionString);
            }
            if (connectionString.StartsWith("metadata="))
            {
                return(connectionString);
            }

            if (platform == DatabasePlatformConstants.MySql)
            {
                return(@"metadata=res://*/Acme.Northwind.EFDAL.Northwind.MySql.csdl|res://*/Acme.Northwind.EFDAL.Northwind.MySql.ssdl|res://*/Acme.Northwind.EFDAL.Northwind.msl;provider=MySql.Data.MySqlClient;provider connection string='" + connectionString + "'");
            }
            else if (platform == DatabasePlatformConstants.SQLServer)
            {
                return(@"metadata=res://*/Acme.Northwind.EFDAL.Northwind.csdl|res://*/Acme.Northwind.EFDAL.Northwind.ssdl|res://*/Acme.Northwind.EFDAL.Northwind.msl;provider=System.Data.SqlClient;provider connection string='" + connectionString + "'");
            }
            else
            {
                throw new Exception("Unknown platform!");
            }
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Creates a new instance of the ContextStartup object
		/// </summary>
		public ContextStartup(string modifier, bool allowLazyLoading, int commandTimeout, DatabasePlatformConstants currentPlatform) :
			this(modifier, allowLazyLoading)
		{
			this.CurrentPlatform = currentPlatform;
			this.CommandTimeout = commandTimeout;
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Creates a new instance of the ContextStartup object
		/// </summary>
		public ContextStartup(string modifier, DatabasePlatformConstants currentPlatform) :
			this(modifier)
		{
			this.CurrentPlatform = currentPlatform;
		}
Ejemplo n.º 6
0
		internal static string ConvertNormalCS2EF(string connectionString, DatabasePlatformConstants platform)
		{
			if (string.IsNullOrEmpty(connectionString)) return connectionString;
			if (connectionString.StartsWith("metadata=")) return connectionString;

			if (platform == DatabasePlatformConstants.MySql)
				return @"metadata=res://*/Acme.Northwind.EFDAL.Northwind.MySql.csdl|res://*/Acme.Northwind.EFDAL.Northwind.MySql.ssdl|res://*/Acme.Northwind.EFDAL.Northwind.msl;provider=MySql.Data.MySqlClient;provider connection string='" + connectionString + "'";
			else if (platform == DatabasePlatformConstants.SQLServer)
				return @"metadata=res://*/Acme.Northwind.EFDAL.Northwind.csdl|res://*/Acme.Northwind.EFDAL.Northwind.ssdl|res://*/Acme.Northwind.EFDAL.Northwind.msl;provider=System.Data.SqlClient;provider connection string='" + connectionString + "'";
			else
				throw new Exception("Unknown platform!");
		}
Ejemplo n.º 7
0
 protected override void OnValueChanging(nHydrateModelBase element, DatabasePlatformConstants oldValue, DatabasePlatformConstants newValue)
 {
     var model = element as nHydrateModel;
     if (!model.IsLoading)
     {
         throw new Exception("Only SQL Server is currently supported. This value cannot be changed.");
     }
     base.OnValueChanging(element, oldValue, newValue);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new instance of the ContextStartup object
 /// </summary>
 public ContextStartup(string modifier, bool allowLazyLoading, int commandTimeout, DatabasePlatformConstants currentPlatform) :
     this(modifier, allowLazyLoading)
 {
     this.CurrentPlatform = currentPlatform;
     this.CommandTimeout  = commandTimeout;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a new instance of the ContextStartup object
 /// </summary>
 public ContextStartup(string modifier, DatabasePlatformConstants currentPlatform) :
     this(modifier)
 {
     this.CurrentPlatform = currentPlatform;
 }