Nx.DBUtility 2.1.0

dotnet add package Nx.DBUtility --version 2.1.0
NuGet\Install-Package Nx.DBUtility -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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
#r "nuget: Nx.DBUtility, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Nx.DBUtility as a Cake Addin
#addin nuget:?package=Nx.DBUtility&version=2.1.0

// Install Nx.DBUtility as a Cake Tool
#tool nuget:?package=Nx.DBUtility&version=2.1.0

A db util for easy sql query

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
    • Nx (>=

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 1,773 12/17/2014
2.0.0 1,340 12/17/2014

       --用于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);