private void Generate( CreateViewOperation operation, MigrationCommandListBuilder builder) { try { var sqlHelper = Dependencies.SqlGenerationHelper; var assembly = AssemblyTool.GetAssemblyByName(operation.AssemblyName); string resourceName = assembly.GetManifestResourceNames() .Single(str => str.EndsWith(operation.ResourceSqlFileName)); using Stream stream = assembly.GetManifestResourceStream(resourceName); using StreamReader reader = new StreamReader(stream ?? throw new InvalidOperationException()); string result = reader.ReadToEnd(); _logger.LogDebug(result); builder.AppendLines(result) .AppendLine(sqlHelper.StatementTerminator) .EndCommand(); } catch (Exception ex) { _logger.LogError("Generate " + ex.Message + " " + ex.StackTrace); } }
protected virtual void AddPolicy(string schema, string table, MigrationCommandListBuilder builder) { if (string.IsNullOrWhiteSpace(schema)) { schema = "dbo"; } builder.AppendLines( $@"ALTER SECURITY POLICY rls.tenantAccessPolicy ADD FILTER PREDICATE rls.fn_tenantAccessPredicate(TenantId) ON {schema}.{table}, ADD BLOCK PREDICATE rls.fn_tenantAccessPredicate(TenantId) ON {schema}.{table}" ); builder.EndCommand(false); }
protected virtual void DropPolicy(string schema, string table, MigrationCommandListBuilder builder) { if (string.IsNullOrWhiteSpace(schema)) { schema = "dbo"; } builder.AppendLines( $@"ALTER SECURITY POLICY rls.tenantAccessPolicy DROP FILTER PREDICATE ON {schema}.{table}, DROP BLOCK PREDICATE ON {schema}.{table}" ); builder.EndCommand(false); }
private void Generate( CreateViewOperation operation, MigrationCommandListBuilder builder) { var sqlHelper = Dependencies.SqlGenerationHelper; //var stringMapping = Dependencies.TypeMappingSource.FindMapping(typeof(string)); var assembly = AssemblyTool.GetAssemblyByName(operation.AssemblyName); //var assembly = Assembly.GetExecutingAssembly(); //Console.WriteLine("Generate: " + assembly.FullName); string resourceName = assembly.GetManifestResourceNames().Single(str => str.EndsWith(operation.ResourceSqlFileName)); //Assembly.GetManifestResouceNames using Stream stream = assembly.GetManifestResourceStream(resourceName); using StreamReader reader = new StreamReader(stream ?? throw new InvalidOperationException()); string result = reader.ReadToEnd(); //.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); builder.AppendLines(result) .AppendLine(sqlHelper.StatementTerminator) .EndCommand(); }
public override MigrationCommandListBuilder AppendLines(string o) { _builder.AppendLines(o); return(this); }