static internal QueryExpression LoadFromXml(XElement item)
        {
            QueryExpression queryExpression = new QueryExpression()
            {
                ColumnSet  = ColumnSet.LoadFromXml(item.Element(Util.ns.a + "ColumnSet")),
                Criteria   = FilterExpression.LoadFromXml(item.Element(Util.ns.a + "Criteria")),
                Distinct   = Util.LoadFromXml <bool>(item.Element(Util.ns.a + "Distinct")),
                EntityName = Util.LoadFromXml <string>(item.Element(Util.ns.a + "EntityName")),
                PageInfo   = PagingInfo.LoadFromXml(item.Element(Util.ns.a + "PageInfo")),
                NoLock     = Util.LoadFromXml <bool>(item.Element(Util.ns.a + "NoLock"))
            };

            foreach (XElement linkEntity in item.Element(Util.ns.a + "LinkEntities").Elements(Util.ns.a + "LinkEntity"))
            {
                queryExpression.LinkEntities.Add(LinkEntity.LoadFromXml(linkEntity));
            }
            foreach (XElement order in item.Element(Util.ns.a + "Orders").Elements(Util.ns.a + "OrderExpression"))
            {
                queryExpression.Orders.Add(OrderExpression.LoadFromXml(order));
            }
            if (item.Element(Util.ns.a + "TopCount") != null)
            {
                queryExpression.TopCount = Util.LoadFromXml <int>(item.Element(Util.ns.a + "TopCount"));
            }
            return(queryExpression);
        }
        static internal LinkEntity LoadFromXml(XElement item)
        {
            LinkEntity linkEntity = new LinkEntity()
            {
                Columns               = ColumnSet.LoadFromXml(item.Element(Util.ns.a + "Columns")),
                EntityAlias           = Util.LoadFromXml <string>(item.Element(Util.ns.a + "EntityAlias")),
                JoinOperator          = Util.LoadFromXml <JoinOperator>(item.Element(Util.ns.a + "JoinOperator")),
                LinkCriteria          = FilterExpression.LoadFromXml(item.Element(Util.ns.a + "LinkCriteria")),
                LinkFromAttributeName = Util.LoadFromXml <string>(item.Element(Util.ns.a + "LinkFromAttributeName")),
                LinkFromEntityName    = Util.LoadFromXml <string>(item.Element(Util.ns.a + "LinkFromEntityName")),
                LinkToAttributeName   = Util.LoadFromXml <string>(item.Element(Util.ns.a + "LinkToAttributeName")),
                LinkToEntityName      = Util.LoadFromXml <string>(item.Element(Util.ns.a + "LinkToEntityName")),
            };

            foreach (XElement childLinkEntity in item.Element(Util.ns.a + "LinkEntities").Elements(Util.ns.a + "LinkEntity"))
            {
                linkEntity.LinkEntities.Add(LinkEntity.LoadFromXml(childLinkEntity));
            }
            return(linkEntity);
        }
        static internal FilterExpression LoadFromXml(XElement item)
        {
            FilterExpression filterExpression = new FilterExpression()
            {
                FilterOperator = Util.LoadFromXml <LogicalOperator>(item.Element(Util.ns.a + "FilterOperator"))
            };

            foreach (XElement condition in item.Element(Util.ns.a + "Conditions").Elements(Util.ns.a + "ConditionExpression"))
            {
                filterExpression.Conditions.Add(ConditionExpression.LoadFromXml(condition));
            }
            foreach (XElement filter in item.Element(Util.ns.a + "Filters").Elements(Util.ns.a + "FilterExpression"))
            {
                filterExpression.Filters.Add(FilterExpression.LoadFromXml(filter));
            }
            if (item.Element(Util.ns.a + "IsQuickFindFilter") != null)
            {
                filterExpression.IsQuickFindFilter = Util.LoadFromXml <bool>(item.Element(Util.ns.a + "IsQuickFindFilter"));
            }
            return(filterExpression);
        }