public MongoReturnDataList <T> Copy(bool Deeply = false) { MongoReturnDataList <T> ret = new MongoReturnDataList <T>(); this.ForEach(a => ret.Add(Deeply ? a.Clone <T>():a)); return(ret); }
public static List <MongoDataDictionary <T> > ToGroup <T>(MongoDataDictionary <T> orgArr, int grpCnt = 0) where T : MongoData { List <MongoDataDictionary <T> > ret = new List <MongoDataDictionary <T> >(); int realcnt = grpCnt; if (grpCnt <= 0) { realcnt = orgArr.Count / 10; } int grpInnerCnt = (int)Math.Floor((double)orgArr.Count / realcnt);//每组个数 int lastInnerCnt = orgArr.Count - grpInnerCnt * (realcnt - 1); for (int i = 0; i < realcnt; i++) { int copycnt = grpInnerCnt; if (i == realcnt - 1) { copycnt = lastInnerCnt; } MongoReturnDataList <T>[] grpcodes = new MongoReturnDataList <T> [copycnt]; Array.Copy(orgArr.Values.ToList().ToArray(), i * grpInnerCnt, grpcodes, 0, copycnt);//复制到数组中去 ret.Add(new MongoDataDictionary <T>(grpcodes)); } return(ret); }
public object Clone() { MongoReturnDataList <T> ret = new MongoReturnDataList <T>(); this.ForEach(a => ret.Add(a.Clone() as T)); return(ret); }
public MongoReturnDataList <T> GetDataByIndies(int[] indies) { MongoReturnDataList <T> ret = new MongoReturnDataList <T>(); for (int i = 0; i < indies.Length; i++) { ret.Add(this[indies[i]]); } return(ret); }
public MongoDataDictionary(MongoReturnDataList <T>[] inputdata) { inputdata.ToList().ForEach((a) => { MongoReturnDataList <T> val = a; if (val == null || val.Count == 0) { return; } this.Add((a[0] as ICodeData).code, a);//如果有一条及以上记录,加入 }); }
public MongoReturnDataList <T> Query(BsonDocument func) { MongoReturnDataList <T> ret = new MongoReturnDataList <T>(); try { List <T> list = this.FindAll(p => (p as MongoData).Compr(func)); //this.Clear(); list.ForEach(p => ret.Add(p)); } catch (Exception ce) { LogLib.LogableClass.ToLog("结果链查询", ce.Message); } return(ret); }
public MongoReturnDataList <T> Query <Field>(string col, Field val) { MongoReturnDataList <T> ret = new MongoReturnDataList <T>(); try { BsonElement bs = new BsonElement(col, BsonValue.Create(val)); //LogLib.LogableClass.ToLog("查询条件", string.Format("{0}=>{1}",col,val)); List <T> list = this.FindAll(p => p.Compr(bs) == true); //this.Clear(); list?.ForEach(p => ret.Add(p)); } catch (Exception ce) { LogLib.LogableClass.ToLog(string.Format("结果链查询错误[{0}]", ce.Message), ce.StackTrace); } return(ret); }
public static MongoDataDictionary <T> ToDirectionary(MongoReturnDataList <T> list, string keyName) { MongoDataDictionary <T> ret = new MongoDataDictionary <T>(); if (list == null) { return(null); } for (int i = 0; i < list.Count; i++) { DetailStringClass obj = list[i] as DetailStringClass; string key = obj.getValue(keyName)?.ToString(); MongoReturnDataList <T> sublist = new MongoReturnDataList <T>(); if (!ret.ContainsKey(key)) { ret.Add(key, sublist); } sublist = ret[key]; sublist.Add(list[i]); ret[key] = sublist; } return(ret); }