private static void ReadPropertiesColumnOptions(MSSqlServerConfigurationSection config, ColumnOptions columnOptions) { SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.ExcludeAdditionalProperties), value => columnOptions.Properties.ExcludeAdditionalProperties = value); SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.DictionaryElementName), value => columnOptions.Properties.DictionaryElementName = value); SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.ItemElementName), value => columnOptions.Properties.ItemElementName = value); SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitDictionaryContainerElement), value => columnOptions.Properties.OmitDictionaryContainerElement = value); SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitSequenceContainerElement), value => columnOptions.Properties.OmitSequenceContainerElement = value); SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitStructureContainerElement), value => columnOptions.Properties.OmitStructureContainerElement = value); SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitElementIfEmpty), value => columnOptions.Properties.OmitElementIfEmpty = value); SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.PropertyElementName), value => columnOptions.Properties.PropertyElementName = value); SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.RootElementName), value => columnOptions.Properties.RootElementName = value); SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.SequenceElementName), value => columnOptions.Properties.SequenceElementName = value); SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.StructureElementName), value => columnOptions.Properties.StructureElementName = value); SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.UsePropertyKeyAsElementName), value => columnOptions.Properties.UsePropertyKeyAsElementName = value); }
private static void ReadAzureManagedIdentitiesOptions(MSSqlServerConfigurationSection config, MSSqlServerSinkOptions sinkOptions) { SetProperty.IfProvided <bool>(config.UseAzureManagedIdentity, nameof(config.UseAzureManagedIdentity.Value), value => sinkOptions.UseAzureManagedIdentity = value); SetProperty.IfProvided <string>(config.AzureServiceTokenProviderResource, nameof(config.AzureServiceTokenProviderResource.Value), value => sinkOptions.AzureServiceTokenProviderResource = value); }
private static void ReadBatchSettings(MSSqlServerConfigurationSection config, MSSqlServerSinkOptions sinkOptions) { SetProperty.IfProvided <int>(config.BatchPostingLimit, nameof(config.BatchPostingLimit.Value), value => sinkOptions.BatchPostingLimit = value); SetProperty.IfProvided <string>(config.BatchPeriod, nameof(config.BatchPeriod.Value), value => sinkOptions.BatchPeriod = TimeSpan.Parse(value, CultureInfo.InvariantCulture)); SetProperty.IfProvided <bool>(config.EagerlyEmitFirstEvent, nameof(config.EagerlyEmitFirstEvent.Value), value => sinkOptions.EagerlyEmitFirstEvent = value); }
private void ReadTableOptions(MSSqlServerConfigurationSection config, SinkOptions sinkOptions) { SetProperty.IfProvided <string>(config.TableName, nameof(config.TableName.Value), value => sinkOptions.TableName = value); SetProperty.IfProvided <string>(config.SchemaName, nameof(config.SchemaName.Value), value => sinkOptions.SchemaName = value); SetProperty.IfProvided <bool>(config.AutoCreateSqlTable, nameof(config.AutoCreateSqlTable.Value), value => sinkOptions.AutoCreateSqlTable = value); }
private static void SetCommonColumnOptions(ColumnConfig source, SqlColumn target) { SetProperty.IfProvidedNotEmpty <string>(source, nameof(target.ColumnName), value => target.ColumnName = value); SetProperty.IfProvided <string>(source, nameof(target.DataType), value => target.SetDataTypeFromConfigString(value)); SetProperty.IfProvided <bool>(source, nameof(target.AllowNull), value => target.AllowNull = value); SetProperty.IfProvided <int>(source, nameof(target.DataLength), value => target.DataLength = value); SetProperty.IfProvided <bool>(source, nameof(target.NonClusteredIndex), value => target.NonClusteredIndex = value); }
private void ReadMiscColumnOptions(MSSqlServerConfigurationSection config, ColumnOptions columnOptions) { SetProperty.IfProvided <bool>(config, nameof(columnOptions.DisableTriggers), value => columnOptions.DisableTriggers = value); SetProperty.IfProvided <bool>(config, nameof(columnOptions.ClusteredColumnstoreIndex), value => columnOptions.ClusteredColumnstoreIndex = value); string pkName = null; SetProperty.IfProvidedNotEmpty <string>(config, "PrimaryKeyColumnName", value => pkName = value); if (pkName != null) { if (columnOptions.ClusteredColumnstoreIndex) { throw new ArgumentException("SQL Clustered Columnstore Indexes and primary key constraints are mutually exclusive."); } foreach (var standardCol in columnOptions.Store) { var stdColOpts = columnOptions.GetStandardColumnOptions(standardCol); if (pkName.Equals(stdColOpts.ColumnName, StringComparison.InvariantCultureIgnoreCase)) { columnOptions.PrimaryKey = stdColOpts; break; } } if (columnOptions.PrimaryKey == null && columnOptions.AdditionalColumns != null) { foreach (var col in columnOptions.AdditionalColumns) { if (pkName.Equals(col.ColumnName, StringComparison.InvariantCultureIgnoreCase)) { columnOptions.PrimaryKey = col; break; } } } if (columnOptions.PrimaryKey == null) { throw new ArgumentException($"Could not match the configured primary key column name \"{pkName}\" with a data column in the table."); } } }
private void ReadStandardColumns(MSSqlServerConfigurationSection config, ColumnOptions columnOptions) { SetCommonColumnOptions(config.Exception, columnOptions.Exception); SetCommonColumnOptions(config.Id, columnOptions.Id); SetCommonColumnOptions(config.Level, columnOptions.Level); SetCommonColumnOptions(config.LogEvent, columnOptions.LogEvent); SetCommonColumnOptions(config.Message, columnOptions.Message); SetCommonColumnOptions(config.MessageTemplate, columnOptions.MessageTemplate); SetCommonColumnOptions(config.PropertiesColumn, columnOptions.Properties); SetCommonColumnOptions(config.TimeStamp, columnOptions.TimeStamp); SetProperty.IfProvided <bool>(config.Level, nameof(columnOptions.Level.StoreAsEnum), value => columnOptions.Level.StoreAsEnum = value); SetProperty.IfProvided <bool>(config.LogEvent, nameof(columnOptions.LogEvent.ExcludeStandardColumns), value => columnOptions.LogEvent.ExcludeStandardColumns = value); SetProperty.IfProvided <bool>(config.LogEvent, nameof(columnOptions.LogEvent.ExcludeAdditionalProperties), value => columnOptions.LogEvent.ExcludeAdditionalProperties = value); ReadPropertiesColumnOptions(config, columnOptions); SetProperty.IfProvided <bool>(config.TimeStamp, nameof(columnOptions.TimeStamp.ConvertToUtc), value => columnOptions.TimeStamp.ConvertToUtc = value); }
private void ReadBatchSettings(MSSqlServerConfigurationSection config, SinkOptions sinkOptions) { SetProperty.IfProvided <int>(config.BatchPostingLimit, nameof(config.BatchPostingLimit.Value), val => sinkOptions.BatchPostingLimit = val); SetProperty.IfProvided <string>(config.BatchPeriod, nameof(config.BatchPeriod.Value), val => sinkOptions.BatchPeriod = TimeSpan.Parse(val, CultureInfo.InvariantCulture)); }