SqlSugar源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

6 years ago
using OrmTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class Demo5_SqlQueryable
{
public static void Init()
{
Console.WriteLine("");
Console.WriteLine("#### SqlQueryable Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
6 years ago
DbType = DbType.SqlServer,
6 years ago
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true
});
int total = 0;
6 years ago
var list = db.SqlQueryable<Student>("select * from [order]").ToPageList(1, 2, ref total);
6 years ago
//by expression
6 years ago
var list2 = db.SqlQueryable<Student>("select * from [order]").Where(it => it.Id == 1).ToPageList(1, 2);
6 years ago
//by sql
6 years ago
var list3 = db.SqlQueryable<Student>("select * from [order]").Where("id=@id", new { id = 1 }).ToPageList(1, 2);
6 years ago
Console.WriteLine("#### SqlQueryable End ####");
}
}
}