private SPModelParameterizedQuery BindParameters(object[] args, ISPModelManagerInternal manager) { CamlParameterBindingHashtable hashtable = new CamlParameterBindingHashtable(manager); for (int i = 0, count = args.Length; i < count; i++) { hashtable[expression.Parameters[i].Name] = args[i]; } foreach (KeyValuePair <string, ParameterEvaluator> item in evaluators) { hashtable[item.Key] = item.Value(args); } SPModelParameterizedQuery other = (SPModelParameterizedQuery)MemberwiseClone(); other.Expression = other.Expression.Bind(hashtable); other.ContentTypeFilterExpression = null; other.args = args; other.Manager = manager; if (parameterNames[PIndexOffset] != null) { other.Offset = Convert.ToInt32(hashtable[parameterNames[PIndexOffset]]); } if (parameterNames[PIndexLimit] != null) { other.Limit = Convert.ToInt32(hashtable[parameterNames[PIndexLimit]]); } return(other); }
public static SPModelParameterizedQuery Create(Expression expression, ISPModelManagerInternal manager) { CommonHelper.ConfirmNotNull(expression, "expression"); CommonHelper.ConfirmNotNull(manager, "manager"); object[] args; ParameterizedExpression pq = ParameterizedExpression.Create(expression, out args); SPModelParameterizedQuery cached = cache.GetInstance(pq, p => new SPModelParameterizedQuery(pq, manager)); return(cached.BindParameters(args, manager)); }
public override object Execute(Expression expression) { if (expression.NodeType == ExpressionType.Constant) { SPModelQuery query1 = new SPModelQuery(manager); PrepQuery(query1); return(manager.GetItems(query1)); } SPModelParameterizedQuery query = SPModelParameterizedQuery.Create(expression, manager); PrepQuery(query); return(query.Execute()); }
public override bool ShouldTransformExpression(SPModelQuery query) { SPModelParameterizedQuery pq = query as SPModelParameterizedQuery; return(pq != null && pq.TaxonomyFields.Count > 0); }