// Constructors

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="handlers">The handlers.</param>
        /// <param name="request">The request.</param>
        /// <param name="descriptor">The descriptor.</param>
        /// <param name="origin">The origin.</param>
        /// <param name="source">The source.</param>
        public SqlStoreProvider(
            HandlerAccessor handlers, QueryRequest request, TemporaryTableDescriptor descriptor,
            StoreProvider origin, ExecutableProvider source)
            : base(handlers, request, descriptor, origin, new[] { source })
        {
            Initialize();
        }
        // Constructors

        protected SqlTemporaryDataProvider(
            HandlerAccessor handlers, QueryRequest request, TemporaryTableDescriptor tableDescriptor,
            CompilableProvider origin, ExecutableProvider[] sources)
            : base(handlers, request, origin, sources)
        {
            this.tableDescriptor = tableDescriptor;
        }
Esempio n. 3
0
        // Constructors

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="handlers">The handlers.</param>
        /// <param name="request">The request.</param>
        /// <param name="tableDescriptor">The table descriptor.</param>
        /// <param name="filterDataSource">The filter data source.</param>
        /// <param name="origin">The origin.</param>
        /// <param name="source">The source.</param>
        public SqlIncludeProvider(
            HandlerAccessor handlers, QueryRequest request,
            TemporaryTableDescriptor tableDescriptor, Func <IEnumerable <Tuple> > filterDataSource,
            IncludeProvider origin, ExecutableProvider source)
            : base(handlers, request, tableDescriptor, origin, new [] { source })
        {
            this.filterDataSource = filterDataSource;
            Initialize();
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="request">A <see cref="QueryRequest"/> instance associated with
        /// the newly created <see cref="SqlProvider"/>.
        /// </param>
        /// <param name="origin">The origin.</param>
        /// <param name="handlers">The handlers.</param>
        /// <param name="sources">The sources.</param>
        public SqlProvider(HandlerAccessor handlers, QueryRequest request,
                           CompilableProvider origin, ExecutableProvider[] sources)
            : base(origin, sources)
        {
            this.handlers = handlers;
            Request       = request;
            if (typeof(SqlProvider) == GetType())
            {
                Initialize();
            }
        }
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="permanentReference">The permanent reference.</param>
 public SqlProvider(SqlProvider provider, SqlTable permanentReference)
     : base(provider.Origin, provider.Sources.Cast <ExecutableProvider>().ToArray())
 {
     this.permanentReference = permanentReference;
     handlers = provider.handlers;
     Request  = provider.Request;
     if (typeof(SqlProvider) == GetType())
     {
         Initialize();
     }
 }
Esempio n. 6
0
        // Constructors

        public Persister(HandlerAccessor handlers, PersistRequestBuilder requestBuilder)
        {
            var providerInfo  = handlers.ProviderInfo;
            var configuration = handlers.Domain.Configuration;

            this.requestBuilder = requestBuilder;

            sortingRequired =
                configuration.Supports(ForeignKeyMode.Reference) &&
                providerInfo.Supports(ProviderFeatures.ForeignKeyConstraints) &&
                !providerInfo.Supports(ProviderFeatures.DeferrableConstraints);
        }
        public StorageSequenceAccessor(HandlerAccessor handlers)
        {
            ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers");

            queryBuilder = handlers.SequenceQueryBuilder;
            domain       = handlers.Domain;

            var providerInfo = handlers.ProviderInfo;

            hasArbitaryIncrement =
                providerInfo.Supports(ProviderFeatures.Sequences) ||
                providerInfo.Supports(ProviderFeatures.ArbitraryIdentityIncrement);
            hasSequences          = providerInfo.Supports(ProviderFeatures.Sequences);
            hasAISettingsInMemory = providerInfo.Supports(ProviderFeatures.AutoIncrementSettingsInMemory);
        }
Esempio n. 8
0
        public string Compile(HandlerAccessor handlers, IndexInfo index)
        {
            var table = SqlDml.TableRef(CreateStubTable(index.ReflectedType.MappingName, index.Filter.Fields.Count));
            // Translation of ColumnRefs without alias seems broken, use original name as alias.
            var columns = index.Filter.Fields
                          .Select(field => field.Column.Name)
                          .Select((name, i) => SqlDml.ColumnRef(table.Columns[i], name))
                          .Cast <SqlExpression>()
                          .ToList();

            var processor = new ExpressionProcessor(index.Filter.Expression, handlers, null, columns);
            var fragment  = SqlDml.Fragment(processor.Translate());
            var result    = handlers.StorageDriver.Compile(fragment).GetCommandText();

            return(result);
        }
        // Constructors

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        public SqlCompiler(HandlerAccessor handlers, CompilerConfiguration configuration)
        {
            Handlers          = handlers;
            OuterReferences   = new BindingCollection <ApplyParameter, Pair <SqlProvider, bool> >();
            Mapping           = configuration.StorageNode.Mapping;
            TypeIdRegistry    = configuration.StorageNode.TypeIdRegistry;
            NodeConfiguration = configuration.StorageNode.Configuration;

            providerInfo             = Handlers.ProviderInfo;
            temporaryTablesSupported = DomainHandler.TemporaryTableManager.Supported;

            if (!providerInfo.Supports(ProviderFeatures.FullFeaturedBooleanExpressions))
            {
                booleanExpressionConverter = new BooleanExpressionConverter(Driver);
            }

            stubColumnMap = new Dictionary <SqlColumnStub, SqlExpression>();
        }
        // Constructors

        public ExpressionProcessor(
            LambdaExpression lambda, HandlerAccessor handlers, SqlCompiler compiler, params IReadOnlyList <SqlExpression>[] sourceColumns)
        {
            ArgumentValidator.EnsureArgumentNotNull(lambda, "lambda");
            ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers");
            ArgumentValidator.EnsureArgumentNotNull(sourceColumns, "sourceColumns");

            this.compiler      = compiler; // This might be null, check before use!
            this.lambda        = lambda;
            this.sourceColumns = sourceColumns;

            providerInfo = handlers.ProviderInfo;
            driver       = handlers.StorageDriver;

            fixBooleanExpressions      = !providerInfo.Supports(ProviderFeatures.FullFeaturedBooleanExpressions);
            emptyStringIsNull          = providerInfo.Supports(ProviderFeatures.TreatEmptyStringAsNull);
            dateTimeEmulation          = providerInfo.Supports(ProviderFeatures.DateTimeEmulation);
            dateTimeOffsetEmulation    = providerInfo.Supports(ProviderFeatures.DateTimeOffsetEmulation);
            memberCompilerProvider     = handlers.DomainHandler.GetMemberCompilerProvider <SqlExpression>();
            specialByteArrayComparison = providerInfo.ProviderName.Equals(WellKnown.Provider.Oracle);

            bindings           = new HashSet <QueryParameterBinding>();
            activeParameters   = new List <ParameterExpression>();
            evaluator          = new ExpressionEvaluator(lambda);
            parameterExtractor = new ParameterExtractor(evaluator);

            if (fixBooleanExpressions)
            {
                booleanExpressionConverter = new BooleanExpressionConverter(driver);
            }
            if (lambda.Parameters.Count != sourceColumns.Length)
            {
                throw Exceptions.InternalError(Strings.ExParametersCountIsNotSameAsSourceColumnListsCount, OrmLog.Instance);
            }
            if (sourceColumns.Any(list => list.Any(c => c.IsNullReference())))
            {
                throw Exceptions.InternalError(Strings.ExSourceColumnListContainsNullValues, OrmLog.Instance);
            }
            sourceMapping = new Dictionary <ParameterExpression, IReadOnlyList <SqlExpression> >();
        }
 public SqlProviderPreparer(HandlerAccessor handlers)
 {
     ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers");
     this.handlers = handlers;
 }