Ejemplo n.º 1
0
        public ODObject GetFirstItemByUniqueField(string collection, string field, string fieldValue, string mode = "eq")
        {
            ODObject          result = null;
            List <XmlElement> entries;

            switch (mode)
            {
            case "contains": {
                entries = this.GetPage(this._dataServiceUrl + collection + "Collection?$filter=substringof('" + fieldValue + "'," + field + ")");
                break;
            }

            case "eq":
            case "equals":
            default: {
                if (fieldValue != "true" && fieldValue != "false")
                {
                    fieldValue = "'" + fieldValue + "'";
                }
                entries = this.GetPage(this._dataServiceUrl + collection + "Collection?$filter=" + field + " eq " + fieldValue);
                break;
            }
            }

            foreach (XmlElement entry in entries)
            {
                if (entry.Name == "entry")
                {
                    result = ODBase.getObjectFromEntry(collection, entry);
                    return(result);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// HIGHLY NOT RECOMMENDED
        /// </summary>
        public List <ODObject> GetAllItemsByQuery(string collection, string query, int maxIterations = 10)
        {
            List <ODObject>   result  = new List <ODObject>();
            List <XmlElement> entries = this.GetAllPages(collection, query, maxIterations);

            foreach (XmlElement entry in entries)
            {
                if (entry.Name == "entry")
                {
                    ODObject item = ODBase.getObjectFromEntry(collection, entry);
                    result.Add(item);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public List <ODObject> GetSomeItemsByQuery(string collection, string query, int skip)
        {
            List <ODObject>   result  = new List <ODObject>();
            List <XmlElement> entries = this.GetPage(this._dataServiceUrl + collection + "Collection?$filter=" + (query != "" ? query : "1 eq 1") + (skip > 0 ? "&$skip=" + skip : ""));

            foreach (XmlElement entry in entries)
            {
                if (entry.Name == "entry")
                {
                    ODObject item = ODBase.getObjectFromEntry(collection, entry);
                    result.Add(item);
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public ODObject GetFirstItemByQuery(string collection, string query)
        {
            ODObject          result  = null;
            List <XmlElement> entries = this.GetPage(this._dataServiceUrl + collection + "Collection?$filter=" + query);

            foreach (XmlElement entry in entries)
            {
                if (entry.Name == "entry")
                {
                    result = ODBase.getObjectFromEntry(collection, entry);
                    return(result);
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
        public Dictionary <string, ODObject> GetDictionaryByUniqueField(string collection, string field, string query, int maxIterations = 10)
        {
            List <XmlElement>             entries = this.GetAllPages(collection, query, maxIterations);
            Dictionary <string, ODObject> result  = new Dictionary <string, ODObject>();

            foreach (XmlElement entry in entries)
            {
                if (entry.Name == "entry")
                {
                    ODObject o = ODBase.getObjectFromEntry(collection, entry);

                    if (o._data.ContainsKey(field))
                    {
                        result[o[field].ToString()] = o;
                    }
                }
            }
            return(result);
        }