Exemplo n.º 1
0
        // 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> >();
        }
        // Constructors

        public ExpressionTranslationContext(ProviderInfo providerInfo, StorageDriver driver, BooleanExpressionConverter booleanExpressionConverter)
        {
            ProviderInfo = providerInfo;
            Driver       = driver;
            BooleanExpressionConverter = booleanExpressionConverter;
        }
 public ExpressionTranslationScope(ProviderInfo providerInfo, StorageDriver driver, BooleanExpressionConverter booleanExpressionConverter)
     : base(new ExpressionTranslationContext(providerInfo, driver, booleanExpressionConverter))
 {
 }