コード例 #1
0
        public FetchElement AddFilter(string type = "and")
        {
            FetchElement filterElement = AddElement("filter");

            filterElement.SetAttribute("type", type);
            return(filterElement);
        }
コード例 #2
0
        /// <summary>
        /// Add a condition element to Current element - a filter element
        /// </summary>
        /// <param name="target">Field on which a filter applies to </param>
        /// <param name="op"></param>
        /// <param name="value"></param>
        /// <returns>Current element for chaining</returns>
        public FetchElement AddCondition(string target, string op, string value = null)
        {
            FetchElement condElement = AddElement("condition");

            condElement.SetAttribute("attribute", target);
            condElement.SetAttribute("operator", op);
            if (!string.IsNullOrEmpty(value))
            {
                condElement.SetAttribute("value", value);
            }
            return(this);
        }
コード例 #3
0
        /// <summary>
        /// Add a link entity to current element
        /// </summary>
        /// <param name="toEntity">Another entity this entity links to </param>
        /// <param name="sourceAttribute"></param>
        /// <param name="targetAttribute"></param>
        /// <param name="optionals">can be anything from the list: link-type (inner, outer), alias, intersect, visible etc</param>
        /// <returns></returns>
        public FetchElement AddLinkEntity(string toEntity, string sourceAttribute, string targetAttribute, Dictionary <string, string> optionals = null)
        {
            FetchElement linkingElement = AddElement("link-entity");

            linkingElement.SetAttribute("name", toEntity);
            linkingElement.SetAttribute("from", sourceAttribute);
            linkingElement.SetAttribute("to", targetAttribute);
            if (optionals != null)
            {
                foreach (KeyValuePair <string, string> item in optionals)
                {
                    linkingElement.SetAttribute(item.Key, item.Value);
                }
            }
            return(linkingElement);
        }
コード例 #4
0
        public FetchXML(string entityName)
        {
            XmlDocument doc = new XmlDocument();

            XmlElement fetchElement = doc.CreateElement("fetch");

            fetchElement.SetAttribute("version", "1.0");
            fetchElement.SetAttribute("mapping", "logical");
            doc.AppendChild(fetchElement);

            XmlElement entityElement = doc.CreateElement("entity");

            fetchElement.AppendChild(entityElement);
            entityElement.SetAttribute("name", entityName);
            EntityElement = new FetchElement(entityElement);
        }
コード例 #5
0
        /// <summary>
        /// Create an attribute element for returning field value
        /// </summary>
        /// <param name="name"></param>
        /// <param name="optionals">e.g. alias, aggregate</param>
        /// <returns></returns>
        public FetchElement AddField(string name, Dictionary <string, string> optionals = null)
        {
            FetchElement field = AddElement("attribute");

            field.SetAttribute("name", name);
            if (optionals != null)
            {
                foreach (KeyValuePair <string, string> item in optionals)
                {
                    // alias: Only characters within the ranges [A-Z], [a-z] or [0-9] or _ are allowed.
                    // The first character may only be in the ranges [A-Z], [a-z] or _.
                    if (item.Key == "alias")
                    {
                        Debug.Assert(rgx.Match(item.Value).Success);
                    }
                    field.SetAttribute(item.Key, item.Value);
                }
            }
            return(this);
        }
コード例 #6
0
        /// <summary>
        /// Add a building block FetchElement created by helper function to Current FetchElement
        /// </summary>
        /// <param name="element"></param>
        public void AddFragment(FetchElement element)
        {
            XmlNode imported = DOC.ImportNode(element.DOC.DocumentElement, true);

            Current.AppendChild(imported);
        }