第一步:NuGet导入程序集
第二步:使用MsSqlContext 创建上下文
string connString = "Your connection string";
MsSqlContext context = new MsSqlContext(connString);
第三步:MsSqlContext 对象默认使用 ROWNUMBER 的分页方式
context.PagingMode = PagingMode.OFFSET_FETCH;
如使用SQL server数据库可以写这一句
第四步:基本查询
IQuery<User> q = context.Query<User>();
q.Where(a => a.Id == 1).FirstOrDefault();
---生成的 sql:
select [Users].[Id] as [Id],[Users].[Name] as [Name],[Users].[Gender] as [Gender],[Users]. [Age] as [Age],[Users].[CityId] as [CityId],[Users].[OpTime] as [OpTime]
from [Users] as [Users]
where [Users].[Id] = 1
本人也会更新这篇后续,官网的地址:http://www.52chloe.com