public override Expression VisitTable(TableExpression tableExpression)
        {
            var exp = tableExpression;
            var versionedQuerySettings = VersionedQuerySettings.Current;

            if (versionedQuerySettings != null && versionedQuerySettings.SystemVersionEnabled && versionedQuerySettings.IsTableVersioned(exp.Schema, exp.Table))
            {
                var identifier = VersionedQuerySettings.ConvertToVersionedIdentifier(exp.Table);
                tableExpression = new TableExpression(identifier, tableExpression.Schema, tableExpression.Alias, tableExpression.QuerySource);
            }

            return(base.VisitTable(tableExpression));
        }
        public TemporalQueryContext(DbContext dbContext, TemporalQuery queryClause, ILogger logger = null)
        {
            this.dbContext   = dbContext;
            this.queryClause = queryClause;
            this.logger      = logger;

            previousSettings = VersionedQuerySettings.Current;

            var forClause = queryClause.GetClause();

            if (string.IsNullOrEmpty(forClause))
            {
                VersionedQuerySettings.Current = null;
            }
            else
            {
                VersionedQuerySettings.Current = new VersionedQuerySettings
                {
                    SystemVersionEnabled = true,
                    ForClause            = forClause,
                    VersionedTables      = GetVersionedTablesFromDbConetxt(dbContext, logger)
                };
            }
        }
        public override void DelimitIdentifier(StringBuilder builder, string identifier)
        {
            string versionedTable         = null;
            var    versionedQuerySettings = VersionedQuerySettings.Current;

            if (versionedQuerySettings != null && versionedQuerySettings.SystemVersionEnabled && VersionedQuerySettings.ParseVersionedIdentifier(identifier, out versionedTable))
            {
                identifier = versionedTable;
            }

            base.DelimitIdentifier(builder, identifier);

            if (versionedTable != null)
            {
                builder.Append(versionedQuerySettings.ForClause);
            }
        }
        public override string DelimitIdentifier(string identifier)
        {
            string versionedTable         = null;
            var    versionedQuerySettings = VersionedQuerySettings.Current;

            if (versionedQuerySettings != null && versionedQuerySettings.SystemVersionEnabled && VersionedQuerySettings.ParseVersionedIdentifier(identifier, out versionedTable))
            {
                identifier = versionedTable;
            }

            var str = base.DelimitIdentifier(identifier);

            return(versionedTable != null ? str + versionedQuerySettings.ForClause : str);
        }