private static IMongoQuery QuantityQuery(String parameterName, Operator optor, String modifier, ValueExpression operand) { Quantity quantity = operand.ToQuantity().Standardize(); string decimals = quantity.GetDecimalSearchableValue(); List<IMongoQuery> queries = new List<IMongoQuery>(); switch (optor) { case Operator.EQ: queries.Add(M.Query.Matches("decimals", new BsonRegularExpression("^" + decimals, "i"))); break; default: queries.Add(ExpressionQuery("value", optor, new BsonDouble((double)quantity.Value))); break; } if (quantity.System != null) queries.Add(M.Query.EQ("system", quantity.System.ToString())); queries.Add(M.Query.EQ("unit", quantity.Units)); IMongoQuery query = M.Query.ElemMatch(parameterName, M.Query.And(queries)); return query; }