Beispiel #1
0
        public static void ProcessSeed()
        {
            var connectionString = Configuration.GetConnectionString("DefaultConnection");

            //Configuration["ConnectionStrings:DefaultConnection"];
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                var sqlPath        = ExtensionUtility.MapPath("~/App_Data/install/seedItem.sql");
                var customCommands = new List <string>();
                customCommands.AddRange(ExtensionUtility.ParseCommands(sqlPath));
                using (var cmd = connection.CreateCommand())
                {
                    connection.Open();
                    if (customCommands != null)
                    {
                        foreach (var strcommand in customCommands)
                        {
                            cmd.CommandText = strcommand;
                        }
                        cmd.Connection  = connection;
                        cmd.CommandType = CommandType.Text;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }