示例#1
0
        internal DbExpression Parse()
        {
            if (_queryExpression != null)
            {
                return(_queryExpression);
            }

            List <DbParameterReferenceExpression> parameters = null;

            if (this.Parameters != null)
            {
                parameters = new List <DbParameterReferenceExpression>(this.Parameters.Count);
                foreach (ObjectParameter parameter in this.Parameters)
                {
                    TypeUsage typeUsage = parameter.TypeUsage;
                    if (null == typeUsage)
                    {
                        // Since ObjectParameters do not allow users to specify 'facets', make
                        // sure that the parameter TypeUsage is not populated with the provider
                        // default facet values.
                        this.ObjectContext.Perspective.TryGetTypeByName(
                            parameter.MappableType.FullName,
                            false /* bIgnoreCase */,
                            out typeUsage);
                    }

                    Debug.Assert(typeUsage != null, "typeUsage != null");

                    parameters.Add(typeUsage.Parameter(parameter.Name));
                }
            }

            DbLambda lambda =
                CqlQuery.CompileQueryCommandLambda(
                    _queryText,                     // Command Text
                    this.ObjectContext.Perspective, // Perspective
                    null,                           // Parser options - null indicates 'use default'
                    parameters,                     // Parameters
                    null                            // Variables
                    );

            Debug.Assert(lambda.Variables == null || lambda.Variables.Count == 0, "lambda.Variables must be empty");

            return(lambda.Body);
        }
        internal DbExpression Parse()
        {
            if (this._queryExpression != null)
            {
                return(this._queryExpression);
            }
            List <DbParameterReferenceExpression> referenceExpressionList = (List <DbParameterReferenceExpression>)null;

            if (this.Parameters != null)
            {
                referenceExpressionList = new List <DbParameterReferenceExpression>(this.Parameters.Count);
                foreach (ObjectParameter parameter in this.Parameters)
                {
                    TypeUsage typeUsage = parameter.TypeUsage;
                    if (typeUsage == null)
                    {
                        this.ObjectContext.Perspective.TryGetTypeByName(parameter.MappableType.FullNameWithNesting(), false, out typeUsage);
                    }
                    referenceExpressionList.Add(typeUsage.Parameter(parameter.Name));
                }
            }
            return(CqlQuery.CompileQueryCommandLambda(this._queryText, (Perspective)this.ObjectContext.Perspective, (ParserOptions)null, (IEnumerable <DbParameterReferenceExpression>)referenceExpressionList, (IEnumerable <DbVariableReferenceExpression>)null).Body);
        }