/// <summary> /// Immutable clone db constructed here /// </summary> /// <param name="msg"></param> /// <param name="msgid"></param> /// <param name="value"></param> /// <param name="lstChi"></param> private void ImmutableCloneDb(string msg, out string msgid, out string value, out List<int> lstChi) { Write("\n Creation of immutable database from query"); WriteLine(); bool status = false; value = ""; DBElement<string, string> elem = new DBElement<string, string>(); XDocument doc = XDocument.Load(new StringReader(msg)); msgid = doc.Descendants("MessageID").Select(i => i).Single().Value; int key = int.Parse(doc.Descendants("Key").Select(i => i).Single().Value); WriteLine("..Creation of new immutable Database from compound queries..\n"); WriteLine("..First we will retrieve the results from the main DB..\n"); DBElement<int, string> elem1 = new DBElement<int, string>(); WriteLine("\n\n..Getting the children of specific key..\n"); status = query.getChildren(db, key, out elem1); //get the children based on the key provided DBFactoryGen<int, string> el = new DBFactoryGen<int, string>(); WriteLine("\n..Children with Key {0} successfully retrieved..\n", key); WriteLine(" Key : {0}", key); elem1.showChildren(); //show the child elements lstChi = new List<int>(); WriteLine("\n..We will store the same in a immutable DB..\n"); if (elem1 != null && elem1.children != null) { foreach (var i in elem1.children) { lstChi.Add(i); } } }
/// <summary> /// Get by GetChildren results are handled here and query constructed /// </summary> /// <param name="status"></param> /// <param name="doc"></param> /// <param name="key"></param> /// <param name="elem"></param> private void GetChildren(out bool status, ref XDocument doc, out int key, out DBElement<int, string> elem) { sb = new StringBuilder(); key = int.Parse(doc.Descendants("Key").Select(i => i).Single().Value); WriteLine("\n\n..Getting the children of specific key..\n"); status = query.getChildren(db, key, out elem); WriteLine("\nChildren for Key:{0} are\n",key); sb.Append(elem.showChildren()); sb.AppendLine(); doc.Descendants("Response").Select(i => i).Single().Value = sb.ToString(); elem.showChildren(); }