/// <summary> /// loads Dictionary "Many" with links to this object /// </summary> public void LoadMany(ODBase odbase, string Collection, string joinField) { List <XmlElement> entries = odbase.GetAllPages(Collection, joinField + " eq guid'" + this.Guid + "'"); List <ODObject> result = new List <ODObject>(); foreach (XmlElement entry in entries) { if (entry.Name == "entry") { ODObject o = new ODObject(); o._data = ODBase.GetEntryFields(entry); o._Collection = Collection; o.Guid = o["Id"].ToString(); result.Add(o); } } if (result.Count > 0) { this.Many[Collection] = result; } else { this.Many.Remove(Collection); } }
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// protected static internal ODObject getObjectFromEntry(string collection, XmlElement entry) { ODObject result = new ODObject(); result._data = ODBase.GetEntryFields(entry); result._binaryDataLink = ODBase.GetDataLink(entry); result._Collection = collection; result.Guid = result["Id"].ToString(); return(result); }
/// <summary> /// Finds and initializes object. Throws exception if not found. /// </summary> public ODObject(ODBase odb, string Collection, string Guid) { this.Guid = Guid; this._Collection = Collection; this._data = null; List <XmlElement> elements = odb.GetPage(odb.GetCollectionPageUrl(Collection) + "Collection(guid'" + Guid + "')"); if (elements.Count == 1) { this._data = ODBase.GetEntryFields(elements[0]); } if (this._data == null || this._data.Count == 0) { throw new Exception(Collection + "Collection(guid'" + Guid + "') not found"); } this._binaryDataLink = ODBase.GetDataLink(elements[0]); }