直接上源码
1 using System;
2 using System.Data;
3 using System.Threading.Tasks;
4 using DbUtility;
5
6 namespace TestDbUtilityConsole
7 {
8 class Program
9 {
10 static SqlDbUtility db = new SqlDbUtility("Data Source=(local);Initial Catalog=ReportServer;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False");
11 static void Main(string[] args)
12 {
13 DataTable dt = GetDataTable().Result;
14 Console.WriteLine(dt.Rows.Count);
15 Console.ReadKey();
16 }
17
18 static async Task<DataTable> GetDataTable()
19 {
20 DataTable dt = await db.T("select * from Roles").ExecuteDataTableAsync();
21 return dt;
22 }
23 }
24 }
结果:8
开发工具:VS2012
组件:ReSharper8.0.2
数据库:SQL Server 2008 R2
默认安装的数据库ReportServer
DbUtility-查询DataTable,码迷,mamicode.com
时间: 2024-11-05 10:04:03