/// <summary> /// 对表达式进行解析,并返回限制数组。 /// </summary> /// <param name="indexes">数据提供者类别。</param> /// <param name="metadataType">架构元数组类型。</param> /// <param name="expression">查询表达式。</param> /// <returns></returns> public static string[] GetRestriction(Dictionary <string, int> indexes, Type metadataType, Expression expression) { var translator = new SchemaQueryTranslator(indexes, metadataType); expression = PartialEvaluator.Eval(expression); return(translator.GetRestrictionValues(expression)); }
/// <summary> /// 对表达式进行解析,并返回限制值字典。 /// </summary> /// <param name="expression">查询表达式。</param> /// <param name="dicRestrMbrs"></param> /// <returns></returns> public static RestrictionDictionary GetRestrictions <T>(Expression expression, Dictionary <Type, List <MemberInfo> > dicRestrMbrs) { if (expression == null) { return(RestrictionDictionary.Empty); } var translator = new SchemaQueryTranslator { _metadataType = typeof(T) }; if (!dicRestrMbrs.TryGetValue(typeof(T), out List <MemberInfo> properties)) { throw new SchemaQueryTranslateException(typeof(T)); } translator._members = properties; expression = PartialEvaluator.Eval(expression); translator.Visit(expression); return(translator._restrDict); }