/// <summary> /// 根据JSON获取查询条件 /// </summary> /// <param name="jobj"></param> /// <returns></returns> private SuuchaExpression GetCondition(JObject jobj) { var condition = SuuchaExpression.Equal(SuuchaExpression.Constant(1), SuuchaExpression.Constant(1)); foreach (var item in jobj) { condition = SuuchaExpression.And(condition, SuuchaExpression.Equal(item.Key, item.Value)); } return(condition); }
/// <summary> /// 生成主键查询条件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="keyList"></param> /// <returns></returns> SuuchaExpression KeyCondition <T>(List <object[]> keyList) { var condition = SuuchaExpression.Equal(SuuchaExpression.Constant(0), SuuchaExpression.Constant(1)); PropertyInfo[] pis = EntityTool.GetKeyProperty <T>(); foreach (var values in keyList) { if (values.Length != pis.Length) { throw new Exception("主键值数量必须为:" + pis.Length); } SuuchaBinaryExpression kExp = null; for (int i = 0; i < pis.Length; i++) { kExp = 0 == i?SuuchaExpression.Equal(pis[i].Name, values[i]) : SuuchaExpression.And(kExp, SuuchaExpression.Equal(pis[i].Name, values[i])); } condition = SuuchaExpression.Or(condition, kExp); } return(condition); }