public SourceGraphSqlModel(SyncModel model, IShellContext context, DataSyncSqlModel dataSync) { _model = model; if (!model.Sources.Any()) { throw new IncorrectRdsDefinitionException("LGM-00000 There are no available sources entities. Try to add source."); } foreach (var item in model.Sources) { var src = new SourceEntitySqlModel(item, dataSync); Entities.Add(src); src.SqlAlias = item.Alias ?? "src_" + Entities.Count; src.InitializeQuerySource(item.DataSource, context, context.Replace(item.SourceTableVariable), context.Replace(item.SourceQueryVariable)); src.MaterializeIfNeeded(); foreach (var colItem in item.Columns) { string alias = colItem.AliasOrName; if (!Columns.ContainsKey(alias)) { Columns[alias] = new SourceColumnSqlModel { Alias = alias, }; } Columns[alias].DbshColumns.Add(colItem); Columns[alias].Entities.Add(src); src.Columns.Add(Columns[alias]); if (!String.IsNullOrEmpty(colItem.Filter)) { Columns[alias].Filters.Add(colItem.Filter); if (colItem.FilterType != Driver.Common.FilterParser.FilterParser.ExpressionType.None) { Columns[alias].FilterType = colItem.FilterType; } } } } }
public void LoadFlatColumns() { foreach (var colItem in _dbsh.Columns) { string alias = colItem.AliasOrName; var col = new SourceColumnSqlModel { Alias = alias, }; Columns.Add(col); col.Entities.Add(this); col.DbshColumns.Add(colItem); if (!String.IsNullOrEmpty(colItem.Filter)) { col.Filters.Add(colItem.Filter); col.FilterType = colItem.FilterType; col.CompileFilter(); } } }
private void AddEntity(SourceEntitySqlModel sourceEntity) { var src = new SourceEntitySqlModel(sourceEntity.Dbsh, _sourceGraph.DataSync); Entities.Add(src); src.SqlAlias = sourceEntity.SqlAlias; src.QuerySource = sourceEntity.QuerySource; src.TableName = sourceEntity.TableName; src.IsExternal = sourceEntity.IsExternal; foreach (var colItem in sourceEntity.Dbsh.Columns) { string alias = colItem.AliasOrName; if (!Columns.ContainsKey(alias)) { Columns[alias] = new SourceColumnSqlModel { Alias = alias, }; } Columns[alias].DbshColumns.Add(colItem); Columns[alias].Entities.Add(src); Columns[alias].FilterType = colItem.FilterType; if (!String.IsNullOrEmpty(colItem.Filter)) { Columns[alias].Filters.Add(colItem.Filter); } src.Columns.Add(Columns[alias]); } }