示例#1
0
 protected virtual XElement BuildNamedQuery(SysNamedQuery query)
 {
     return(new XElement(DefaultNamespace + "sql-query",
                         new XAttribute("name", query.Name),
                         BuildNamedQueryReturns(query),
                         BuildNamedQueryParameters(query),
                         new XText(query.Query)));
 }
示例#2
0
        protected virtual IEnumerable <XElement> BuildNamedQueryParameters(SysNamedQuery query)
        {
            if (query.Parameters == null)
            {
                yield break;
            }

            foreach (var parameter in query.Parameters)
            {
                yield return(BuildNamedQueryParameter(parameter));
            }
        }
示例#3
0
        protected virtual IEnumerable <XElement> BuildNamedQueryReturns(SysNamedQuery query)
        {
            if (query.ReturnParameters == null)
            {
                yield break;
            }

            foreach (var returnParameter in query.ReturnParameters)
            {
                var scalar = returnParameter as SysNamedQueryReturnScalar;
                if (scalar != null)
                {
                    yield return(BuildScalarReturnParameter(scalar));

                    continue;
                }

                var join = returnParameter as SysNamedQueryReturnJoin;
                if (join != null)
                {
                    yield return(BuildJoinReturnParameter(join));

                    continue;
                }

                var res = returnParameter as SysNamedQueryReturn;
                if (res != null)
                {
                    yield return(BuildReturnParameter(res));

                    continue;
                }

                throw new NotSupportedException(string.Format("Return parameter with type '{0}' is not supported.",
                                                              returnParameter));
            }
        }