/// <summary> /// Run raw sql /// </summary> /// <param name="sql"></param> public static void Run(this string sql) { using (var scope = new TransactionScope()) { var sqlqueries = sql.Split(new[] { "GO" }, StringSplitOptions.RemoveEmptyEntries); var siteConfiguration = SiteInitializer.GetHttpSiteConfiguration(); var connectionString = siteConfiguration != null ? siteConfiguration.ConnectionString : ConfigurationManager.ConnectionStrings[EzCMSEntityConstants.EzCMSEntities].ConnectionString; var con = new SqlConnection(connectionString); var cmd = new SqlCommand("", con); con.Open(); foreach (var query in sqlqueries) { cmd.CommandText = query; cmd.ExecuteNonQuery(); } con.Close(); scope.Complete(); } }
/// <summary> /// Constructor /// </summary> public EzCMSEntities() : base(SiteInitializer.GetHttpSiteConfiguration() == null ? "Name=" + EzCMSEntityConstants.EzCMSEntities : SiteInitializer.GetHttpSiteConfiguration().ConnectionString) { }