private IMongoQuery ChainQuery(ChainedParameter parameter) { IEnumerable <BsonValue> collector = null; IMongoQuery query = parameter.Parameter.ToQuery(); int last = parameter.Joins.Count - 1; for (int i = last; i >= 0; i--) { collector = CollectKeys(query); Join join = parameter.Joins[i]; query = M.Query.In(join.Field, collector); if (join.Resource != null) { query = M.Query.And(query, M.Query.EQ(InternalField.RESOURCE, join.Resource)); } } return(query); }
public ChainedParameter CreateChainedParameter(string resource, string key, string value) { ChainedParameter parameter = new ChainedParameter(); parameter.Strain = Strain.Chained; string[] segments = key.Split('.'); string field, modifier; int last = segments.Count() - 1; for (int i = 0; i < last; i++) { Join join = new Join(); split(segments[i], ':', out field, out modifier); join.Field = field; join.Resource = resource; join.Argument = this.DetermineArgument(join); resource = modifier; parameter.Joins.Add(join); } string _key = segments[last];// field+modifier; parameter.Parameter = this.ExtractParameter(resource, _key, value); return parameter; }