/// <summary> /// Registers an external parameter /// Since these can be complex expressions, we don't try to identify them /// and push them every time /// The only loss may be a small memory loss (if anyone can prove me that the same Expression can be used twice) /// </summary> /// <param name="expression"></param> /// <param name="alias"></param> /// <param name="builderContext"></param> /// <returns></returns> public virtual InputParameterExpression RegisterParameter(Expression expression, string alias, BuilderContext builderContext) { var queryParameterExpression = new InputParameterExpression(expression, alias); builderContext.ExpressionQuery.Parameters.Add(queryParameterExpression); return queryParameterExpression; }
public virtual void UnregisterParameter(InputParameterExpression expression, BuilderContext builderContext) { builderContext.ExpressionQuery.Parameters.Remove(expression); }
private static SqlStatement BuildExpression(ISqlProvider sqlProvider, InputParameterExpression inputParameterExpression) { var alias = inputParameterExpression.Alias; if (inputParameterExpression.IsMutiple) { var parameterss = ((IEnumerable) inputParameterExpression.GetValue()).Cast<object>(); var statements = parameterss.Select((p, id) => { var nameBase = string.Format("{0}{1}", alias, id); return new SqlStatement(new SqlParameterPart(sqlProvider.GetParameterName(nameBase), nameBase)); }).ToArray(); return new SqlStatement(sqlProvider.GetLiteral(statements)); } return new SqlStatement(new SqlParameterPart(sqlProvider.GetParameterName(alias), alias)); }