Nx.DBUtility 2.1.0

A db util for easy sql query

Install-Package Nx.DBUtility -Version 2.1.0
dotnet add package Nx.DBUtility --version 2.1.0
<PackageReference Include="Nx.DBUtility" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nx.DBUtility --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Release Notes

       --用于DBUtility翻页功能 BEGIN
       CREATE PROCEDURE [dbo].[sp_DataGroupPageForDuoTable]
       @rowcount int output, --总记录数,共有几条信息
       @PageSize int, --每页显示记录条数
       @PageIndex int, --第几页
       @wheresql nvarchar(1000), --SQL条件语句
       @ordersql nvarchar(200), --SQL排序语句
       @TableName nvarchar(1000), --查询表名称
       @filed nvarchar(1000)
       declare @mainsql nvarchar(4000)
       declare @fieldsql nvarchar(4000)
       declare @rownumbersql nvarchar(4000)
       declare @exesql nvarchar(4000)
       declare @countsql nvarchar(4000)

       set @mainsql = @TableName +' where 1=1 ' + @wheresql
       set @fieldsql = ' '+@filed+' '   
       set @rownumbersql = 'select row_number() over('+@ordersql+') as pos,'+@fieldsql+' from '+@mainsql
       set @exesql = 'SELECT * FROM ('+@rownumbersql+') AS sp WHERE pos BETWEEN '+str((@PageIndex-1)*@PageSize+1)+' AND '+str(@PageIndex*@PageSize)
       set @countsql='select @totalcount=count(*) from '+ @mainsql
       print @exesql
       exec sp_executesql @countsql,N'@totalcount int out',@rowcount output
       exec (@exesql)
       --用于DBUtility翻页功能 END
     //配置App.config or web.config
           <add key="ConnectionString" value="Data Source=;Initial Catalog=testdb;User ID=sa;Password=yourpwd"/>
     static void Main(string[] args)
         SqlPagedData pagedData = new SqlPagedData(
             startPageIndex: 1,
             pageSize: 200,
             sqlWhere: " and cid>10000",
             tableName: "Client",
             sqlOrderBy: " order by cid desc  ",
             fileds: "cid,tel,email");

         while (true)
             var item = pagedData.Next();
             if (item == null)
             //情况1:如果构造函数时传入的fields为星号(*), 那么属性名的大小写必须和数据库字段大小写相同。
             Console.WriteLine("{0} {1} {2} i:{3}", item.cid, item.tel, item.email, item.tel + " i:" + pagedData.Position.PageIndex);

         var pos = pagedData.Position;

         pagedData = new SqlPagedData(pos);
         while (true)
             var item = pagedData.Next();
             if (item == null)
             Console.WriteLine("{0} {1} {2} i:{3}", item.cid, item.tel, item.email, item.tel + " i:" + pagedData.Position.PageIndex);

    • Nx (>=

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.1.0 664 12/17/2014
2.0.0 368 12/17/2014