SqlSugar/OrmTest/ExpressionTest/Join.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2017-02-26 23:56:28 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2017-02-27 01:03:56 +08:00
using SqlSugar;
using System.Linq.Expressions;
using OrmTest.Models;
2017-02-26 23:56:28 +08:00
namespace OrmTest.ExpressionTest
{
2017-02-27 01:03:56 +08:00
public class Join : ExpTestBase
2017-02-26 23:56:28 +08:00
{
2017-02-27 01:03:56 +08:00
private Join() { }
public Join(int eachCount)
{
this.Count = eachCount;
}
internal void Init()
{
base.Begin();
for (int i = 0; i < base.Count; i++)
{
Q2();
}
base.End("Method Test");
}
public void Q2()
{
2017-03-04 00:54:19 +08:00
using (var db = GetInstance())
{
var list = db.Queryable<Student, School>((st, sc) => new object[] {
JoinType.Left,st.SchoolId==sc.Id
2017-03-04 01:19:25 +08:00
}).Where(st=>st.Id>0).ToList();
2017-03-04 00:54:19 +08:00
}
}
2017-02-27 01:03:56 +08:00
2017-03-04 00:54:19 +08:00
public SqlSugarClient GetInstance()
{
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
return db;
2017-02-27 01:03:56 +08:00
}
2017-02-26 23:56:28 +08:00
}
}