Inheritance: INameable, IScriptable
Exemple #1
0
        public void Assembly_WithPermissionSetCases(string permissionSet, string scriptedPermissionSet) {
            var assembly = new SqlAssembly(permissionSet, "SchemazenAssembly");
            assembly.Files.Add(new KeyValuePair<string, byte[]>("mydll", new byte[0]));

		    var expected = @"CREATE ASSEMBLY [SchemazenAssembly]
FROM 0x
WITH PERMISSION_SET = " + scriptedPermissionSet;
		    Assert.AreEqual(expected, assembly.ScriptCreate());
		}
Exemple #2
0
		private void LoadCLRAssemblies(SqlCommand cm) {
			try {
				// get CLR assemblies
				cm.CommandText = @"select a.name as AssemblyName, a.permission_set_desc, af.name as FileName, af.content
						from sys.assemblies a
						inner join sys.assembly_files af on a.assembly_id = af.assembly_id 
						where a.is_user_defined = 1
						order by a.name, af.file_id";
				SqlAssembly a = null;
				using (var dr = cm.ExecuteReader()) {
					while (dr.Read()) {
						if (a == null || a.Name != (string) dr["AssemblyName"])
							a = new SqlAssembly((string) dr["permission_set_desc"], (string) dr["AssemblyName"]);
						a.Files.Add(new KeyValuePair<string, byte[]>((string) dr["FileName"], (byte[]) dr["content"]));
						if (!Assemblies.Contains(a))
							Assemblies.Add(a);
					}
				}
			} catch (SqlException) {
				// SQL server version doesn't support CLR assemblies, nothing to do here
			}
		}