private static void VisitAbstractMatch(EnumerableVisitor visitor, MethodCallExpression node, string format) { var fragment = visitor.Push(visitor.Peek.Fragment <IBinaryExpressionBuilder>()); try { visitor.Visit(node.Object); visitor.Peek.Write(visitor.Peek.CreateOperator(QueryOperator.Match)); visitor.Visit(node.Arguments); } finally { visitor.Pop(); } var parameter = fragment.Right as IParameterBuilder; if (parameter != null) { visitor.Constants[parameter.Name] = string.Format( format, visitor.Constants[parameter.Name] ); } else { //TODO: Warn, expected parameter was not found. } visitor.Peek.Write(fragment); }
protected virtual IDatabaseSet Set(Expression expression) { var set = this.Database.Set <T>(this.Source.Clone()); var visitor = new EnumerableVisitor(this, this.Database, set.Fetch, set.ElementType); visitor.Visit(expression); if (set.Parameters != null) { set.Parameters = (DatabaseParameterHandler)Delegate.Combine(set.Parameters, visitor.Parameters); } else { set.Parameters = visitor.Parameters; } return((IDatabaseSet)set); }
public static void VisitStartsWith(EnumerableVisitor visitor, MethodCallExpression node) { VisitAbstractMatch(visitor, node, "{0}%"); }
public static void VisitContains(EnumerableVisitor visitor, MethodCallExpression node) { VisitAbstractMatch(visitor, node, "%{0}%"); }