/// <summary> /// 查询函数(AND)与操作 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="db"></param> /// <param name="paras">为两个参数一组,第一个为字段名,第二个为搜索Key值</param> /// <returns></returns> public static T[] Find <T>(IObjectContainer db, JoinType joinType, ContainType constrainType, IDB4OCompare dbCompareImp, params Dictionary <string, string>[] paras) { //IQuery q = db.Query(); //q.Constrain(T); try { IQuery retQuery = db.Query(); retQuery.Constrain(typeof(T)); if (paras.Length > 0) { foreach (Dictionary <string, string> dic in paras) { foreach (KeyValuePair <string, string> pair in dic) { IQuery temp = retQuery.Descend(pair.Key); IConstraint constrain = GetConstraintByType(temp, pair.Value, constrainType); GetJointByType(retQuery.Constraints(), constrain, joinType); } } } retQuery.SortBy(dbCompareImp); IObjectSet result = retQuery.Execute(); T[] retArray = new T[result.Count]; for (int i = 0; i < result.Count; i++) { retArray[i] = (T)result[i]; } return(retArray); } catch (Exception ex) { throw ex; } }
public JsonContainer(Stream stream) { JsonContainer parsed = Parse(stream); ContainerType = parsed.ContainerType; container = parsed.container; }
public static IConstraint GetConstraintByType(IQuery query, string key, ContainType type) { if (type == ContainType.EndsWith) { return(query.Constrain(key).EndsWith(false)); } if (type == ContainType.EndsWithCaseSensitive) { return(query.Constrain(key).EndsWith(true)); } if (type == ContainType.StartsWith) { return(query.Constrain(key).StartsWith(false)); } if (type == ContainType.EndsWithCaseSensitive) { return(query.Constrain(key).EndsWith(true)); } if (type == ContainType.Like) { return(query.Constrain(key).Like()); } if (type == ContainType.Greater) { return(query.Constrain(key).Greater()); } if (type == ContainType.Smaller) { return(query.Constrain(key).Smaller()); } if (type == ContainType.Identity) { return(query.Constrain(key).Identity()); } if (type == ContainType.Equal) { return(query.Constrain(key).Equal()); } throw new NotSupportedException(); }
public static IObjectSet Find(IObjectContainer db, Type t, JoinType joinType, ContainType constrainType, params Dictionary <string, string>[] paras) { try { IQuery retQuery = db.Query(); retQuery.Constrain(t); if (paras.Length > 0) { foreach (Dictionary <string, string> dic in paras) { foreach (KeyValuePair <string, string> pair in dic) { IQuery temp = retQuery.Descend(pair.Key); IConstraint constrain = GetConstraintByType(temp, pair.Value, constrainType); //if (paras.Length > 1 && dic.Keys.Count > 1) GetJointByType(retQuery.Constraints(), constrain, joinType); } } } IObjectSet result = retQuery.Execute(); //object[] retObject = null; //if (result != null && result.Count>0) //{ // retObject = new object[result.Count]; // int i = 0; // while (result.HasNext()) // { // retObject[i] = result.Next(); // i++; // } //} return(result); } catch (Exception ex) { throw ex; } }
public JsonContainer(ContainType containerType) { ContainerType = containerType; }