internal QueryParameterExpression(
     DbParameterReferenceExpression parameterReference,
     Expression funcletizedExpression,
     IEnumerable<ParameterExpression> compiledQueryParameters)
 {
     Contract.Requires(parameterReference != null);
     Contract.Requires(funcletizedExpression != null);
     _compiledQueryParameters = compiledQueryParameters ?? Enumerable.Empty<ParameterExpression>();
     _parameterReference = parameterReference;
     _type = funcletizedExpression.Type;
     _funcletizedExpression = funcletizedExpression;
     _cachedDelegate = null;
 }
        internal QueryParameterExpression(
            DbParameterReferenceExpression parameterReference,
            Expression funcletizedExpression,
            IEnumerable<ParameterExpression> compiledQueryParameters)
        {
            DebugCheck.NotNull(parameterReference);
            DebugCheck.NotNull(funcletizedExpression);

            _compiledQueryParameters = compiledQueryParameters ?? Enumerable.Empty<ParameterExpression>();
            _parameterReference = parameterReference;
            _type = funcletizedExpression.Type;
            _funcletizedExpression = funcletizedExpression;
            _cachedDelegate = null;
        }
        public override Expression Visit(DbParameterReferenceExpression expression)
        {
            Type type = edmTypeConverter.Convert(expression.ResultType);

            ConstructorInfo parameterPlaceholderConstructor = 
                typeof(NMemory.StoredProcedures.Parameter<>)
                    .MakeGenericType(type)
                    .GetConstructors()
                    .Single(c => c.GetParameters().Count() == 1);

            NewExpression parameter = 
                Expression.New(
                    parameterPlaceholderConstructor, 
                    Expression.Constant(expression.ParameterName));

            // Add implicit conversion
            return Expression.Convert(parameter, type);
        }
Example #4
0
 internal QueryParameterExpression(
     DbParameterReferenceExpression parameterReference,
     Expression funcletizedExpression,
     IEnumerable<ParameterExpression> compiledQueryParameters)
 {
     EntityUtil.CheckArgumentNull(parameterReference, "parameterReference");
     EntityUtil.CheckArgumentNull(funcletizedExpression, "funcletizedExpression");
     _compiledQueryParameters = compiledQueryParameters ?? Enumerable.Empty<ParameterExpression>();
     _parameterReference = parameterReference;
     _type = funcletizedExpression.Type;
     _funcletizedExpression = funcletizedExpression;
     _cachedDelegate = null;
 }
		public override void Visit(DbParameterReferenceExpression expression)
		{
			throw new NotSupportedException("Visit(\"ParameterReferenceExpression\") is not supported.");
		}
 /// <summary>
 ///     Visitor pattern method for <see cref="DbParameterReferenceExpression" />.
 /// </summary>
 /// <param name="expression"> The DbParameterReferenceExpression that is being visited. </param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="expression" />
 ///     is null
 /// </exception>
 public override void Visit(DbParameterReferenceExpression expression)
 {
     // #433613: PreSharp warning 56506: Parameter 'expression' to this public method must be validated: A null-dereference can occur here.
     Check.NotNull(expression, "expression");
 }
 public override DbExpression Visit(DbParameterReferenceExpression expression)
 {
     // Inline parameters
     return DbExpressionBuilder.Constant(_parameters[expression.ParameterName].Value);
 }
            public override DbExpression Visit(DbParameterReferenceExpression expression)
            {
                Check.NotNull(expression, "expression");

                if (objectParameters.Contains(expression.ParameterName))
                {
                    // A DbNullExpression is required for null values; DbConstantExpression otherwise.
                    var objParam = objectParameters[expression.ParameterName];
                    if (null == objParam.Value)
                    {
                        return expression.ResultType.Null();
                    }
                    else
                    {
                        // This will throw if the value is incompatible with the result type.
                        return expression.ResultType.Constant(objParam.Value);
                    }
                }
                return expression;
            }
            public override void Visit(DbParameterReferenceExpression expression)
            {
                Check.NotNull(expression, "expression");

                var parameter
                    = CreateParameter(
                        DBNull.Value,
                        expression.ResultType,
                        "@" + expression.ParameterName);

                _commandText.Append(parameter.ParameterName);
            }
            public override void Visit(DbParameterReferenceExpression expression)
            {
                DebugCheck.NotNull(expression);

                _where.Append("@" + expression.ParameterName);
            }
        public override void Visit(DbParameterReferenceExpression expression)
        {
            Debug.Assert(expression != null, "Command tree subexpressions should never be null");

            paramMappings[expression.ParameterName] = expression;
        }
 public override void Visit(DbParameterReferenceExpression e)
 {
     Dictionary<string, object> attrs = new Dictionary<string, object>();
     attrs.Add("ParameterName", e.ParameterName);
     Begin(e, attrs);
     End(e);
 }
 public override void Visit(DbParameterReferenceExpression expression) { }
 public override DbExpression Visit(DbParameterReferenceExpression expression)
 {
     System.Diagnostics.Debug.Print("Visit(DbParameterReferenceExpression): {0}", expression);
     return base.Visit(expression);
 }
        public override void Visit(DbParameterReferenceExpression expression)
        {
            Check.NotNull(expression, "expression");

            paramMappings[expression.ParameterName] = expression;
        }
 /// <summary>
 ///     Visitor pattern method for DbParameterReferenceExpression.
 /// </summary>
 /// <param name="expression"> The DbParameterReferenceExpression that is being visited. </param>
 public abstract void Visit(DbParameterReferenceExpression expression);
 public override void Visit(DbParameterReferenceExpression e)
 {
     _key.Append("@");
     _key.Append(e.ParameterName);
     _key.Append(":");
     _key.Append(e.ResultType.Identity);
 }
 public override void Visit(DbParameterReferenceExpression expression)
 {
     Contract.Requires(expression != null);
 }
Example #19
0
 public override void Visit(DbParameterReferenceExpression expression)
 {
   if (expression == null) throw new ArgumentException("expression");
 }
 /// <summary>
 ///     Visitor pattern method for <see cref="DbParameterReferenceExpression" />.
 /// </summary>
 /// <param name="expression"> The DbParameterReferenceExpression that is being visited. </param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="expression" />
 ///     is null
 /// </exception>
 public override void Visit(DbParameterReferenceExpression expression)
 {
     Check.NotNull(expression, "expression");
 }