SqlSugar/OrmTest/UnitTest/Query/SelectQuery.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2017-03-04 01:22:06 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using System.Linq.Expressions;
using OrmTest.Models;
2017-03-04 15:07:58 +08:00
namespace OrmTest.UnitTest
2017-03-04 01:22:06 +08:00
{
2017-03-05 00:29:53 +08:00
public class SelectQuery : ExpTestBase
2017-03-04 01:22:06 +08:00
{
2017-03-05 00:29:53 +08:00
private SelectQuery() { }
public SelectQuery(int eachCount)
2017-03-04 01:22:06 +08:00
{
this.Count = eachCount;
}
internal void Init()
{
base.Begin();
for (int i = 0; i < base.Count; i++)
{
Q2();
}
base.End("Method Test");
}
public void Q2()
{
using (var db = GetInstance())
{
2017-03-05 17:15:36 +08:00
//var list = db.Queryable<Student>()
// .Where(st => st.Id > 0)
// .Select(it => new ViewModelStudent { Name = it.Name }).ToList();
2017-03-06 01:18:01 +08:00
//var list2 = db.Queryable<Student>()
// .Where(st => st.Id > 0)
// .Select("id").ToList();
var list3 = db.Queryable<Student>()
.Where(st => st.Id > 0)
.Select(it => new ViewModelStudent2 { Student = it }).ToList();
2017-03-04 01:22:06 +08:00
}
}
public SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
return db;
}
}
}