当前位置: 首页>>代码示例>>C#>>正文


C# IQuery.ThrowIfNullArgument方法代码示例

本文整理汇总了C#中IQuery.ThrowIfNullArgument方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.ThrowIfNullArgument方法的具体用法?C# IQuery.ThrowIfNullArgument怎么用?C# IQuery.ThrowIfNullArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQuery的用法示例。


在下文中一共展示了IQuery.ThrowIfNullArgument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PagedQuery

        public override string PagedQuery(IQuery query, uint numberPerPage, uint page)
        {
            query.ThrowIfNullArgument(nameof(query));
            if (page == 0 || numberPerPage == 0)
                GenerateExceptionHelper.ThrowMustGreaterThanZero();

            if (query.Order == null)
                GenerateExceptionHelper.ThrowPagedQueryMustSpecifyOrder();

            try
            {
                string pagedQuery = "SELECT * FROM (SELECT row_.*, rownum rownum_ FROM ({0}) row_ WHERE rownum <= {1}) WHERE rownum_ > {2}";
                var n1 = numberPerPage * page;
                var n2 = numberPerPage * (page - 1);

                var svList = _vv.VisitAlias(query.View);

                StringBuilder str = new StringBuilder();
                str.Append(_tr.Select).Append(_cb.BuildSelectColumns(query.View));
                str.Append(_tr.From).Append(_vv.BuildJoinClause(query.View));
                if (query.Criteria != null)
                {
                    str.Append(_tr.Where).Append(_cv.BuildWhereFilters(query.Criteria, svList));
                }

                str.Append(_tr.OrderBy).Append(_ov.BuildOrderClause(query.Order, svList));
                return string.Format(pagedQuery, str, n1, n2);
            }
            catch (Exception ex)
            {
                throw ex.CreateWrapException<SQLGenerateException>();
            }
        }
开发者ID:rexzh,项目名称:RexToy,代码行数:33,代码来源:QuerySQLEmit.cs

示例2: PagedQuery

        public override string PagedQuery(IQuery query, uint numberPerPage, uint page)
        {
            query.ThrowIfNullArgument(nameof(query));
            if (page == 0 || numberPerPage == 0)
                GenerateExceptionHelper.ThrowMustGreaterThanZero();

            if (query.Order == null)
                GenerateExceptionHelper.ThrowPagedQueryMustSpecifyOrder();

            try
            {
                IReadOnlyList<SingleEntityView> svList = _vv.VisitAlias(query.View);
                StringBuilder sql = new StringBuilder();
                if (page == 1)
                {
                    sql.Append(_tr.Select).AppendFormat(TOP_N, numberPerPage);
                    sql.Append(_cb.BuildSelectColumns(query.View));
                    sql.Append(_tr.From).Append(_vv.BuildJoinClause(query.View));
                    if (query.Criteria != null)
                    {
                        sql.Append(_tr.Where);
                        sql.Append(_cv.BuildWhereFilters(query.Criteria, svList));
                    }
                    sql.Append(_tr.OrderBy).Append(_ov.BuildOrderClause(query.Order, svList));
                    return sql.ToString();
                }
                else
                {
                    StringBuilder sub = new StringBuilder();
                    sub.Append(_tr.Select).AppendFormat(TOP_N, (page - 1) * numberPerPage).Append(_ov.BuildOrderSelectColumns(query.Order, svList));
                    sub.Append(_tr.From).Append(_vv.BuildJoinClause(query.View));
                    if (query.Criteria != null)
                    {
                        sub.Append(_tr.Where).Append(_cv.BuildWhereFilters(query.Criteria, svList));
                    }
                    sub.Append(_tr.OrderBy).Append(_ov.BuildOrderClause(query.Order, svList));

                    sql.Append(_tr.Select).AppendFormat(TOP_N, numberPerPage).Append(_cb.BuildSelectColumns(query.View));
                    sql.Append(_tr.From).Append(_vv.BuildJoinClause(query.View));
                    sql.Append(_tr.Where).Append(_ov.BuildOrderSelectColumns(query.Order, svList)).Append(_tr.NotIn).Append(sub.Bracketing(StringPair.Parenthesis));
                    if (query.Criteria != null)
                    {
                        sql.Append(_tr.And).Append(_cv.BuildWhereFilters(query.Criteria, svList));
                    }
                    sql.Append(_tr.OrderBy).Append(_ov.BuildOrderClause(query.Order, svList));

                    return sql.ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex.CreateWrapException<SQLGenerateException>();
            }
        }
开发者ID:rexzh,项目名称:RexToy,代码行数:54,代码来源:QuerySQLEmit.cs


注:本文中的IQuery.ThrowIfNullArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。