public void Reset() { Name = null; Schema = null; Context = null; _columns = null; _sql = null; _tabularData = null; }
public DirectoryTabularDataReader(IShellContext context, ITabularDataSource source, string propertyName, string[] files) { this._context = context; this._source = source; this._propertyName = propertyName; this._files = files; NextRefReader(); }
public void InitializeQuerySource(ITabularDataSource dataSource, IShellContext context, string sourceTableVariable, string sourceQueryVariable) { if (!_dbsh.ForceExternalSource) { // try to create non-external source var tableOrView = dataSource as DbShell.Core.Utility.TableOrView; if (!String.IsNullOrEmpty(sourceTableVariable)) { QuerySource = new DmlfSource { Alias = SqlAlias, TableOrView = new NameWithSchema($"###({sourceTableVariable})###"), }; TableName = new NameWithSchema(sourceTableVariable); return; } if (!String.IsNullOrEmpty(sourceQueryVariable)) { QuerySource = new DmlfSource { Alias = SqlAlias, SubQueryString = $"###({sourceQueryVariable})###", }; return; } if (tableOrView != null) { bool canUseTable = true; LinkedDatabaseInfo linked = null; var ctxConn = new NormalizedDatabaseConnectionInfo(new DatabaseConnectionInfoHolder { ProviderString = context.GetDefaultConnection() }); var tableConn = tableOrView.GetNormalizedConnectionInfo(context); if (ctxConn != tableConn) { if (ctxConn.ServerConnectionString == tableConn.ServerConnectionString) { linked = tableConn.GetLinkedInfo(); } else { canUseTable = false; } } if (canUseTable) { TableName = tableOrView.GetFullName(context); QuerySource = new DmlfSource { Alias = SqlAlias, TableOrView = TableName, LinkedInfo = linked, }; return; } } var query = dataSource as DbShell.Core.Query; if (query != null && query.GetProviderString(context) == context.GetDefaultConnection()) { string sql = context.Replace(query.Text); QuerySource = new DmlfSource { Alias = SqlAlias, SubQueryString = sql, }; return; } } IsExternal = true; _externalDataName = new NameWithSchema(null, $"##{SqlAlias}_{new Random().Next(10000, 100000)}"); QuerySource = new DmlfSource { Alias = SqlAlias, TableOrView = _externalDataName, }; _dataSync.AddExternalSource(this); }
public void LoadFromReader(ITabularDataSource source, NameWithSchema targetTable, IShellContext context) { using (var reader = source.CreateReader(context)) { DoLoadRows(reader, targetTable); } }
public void LoadTable(ITabularDataSource source, NameWithSchema targetTable, IShellContext context) { CheckUnprepared("LoadTable"); LoadFromReader(source, targetTable, context); }