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.
61 lines
1.7 KiB
61 lines
1.7 KiB
8 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
8 years ago
|
using SqlSugar;
|
||
|
using System.Linq.Expressions;
|
||
|
using OrmTest.Models;
|
||
8 years ago
|
namespace OrmTest.UnitTest
|
||
8 years ago
|
{
|
||
8 years ago
|
public class JoinQuery : ExpTestBase
|
||
8 years ago
|
{
|
||
8 years ago
|
private JoinQuery() { }
|
||
|
public JoinQuery(int eachCount)
|
||
8 years ago
|
{
|
||
|
this.Count = eachCount;
|
||
|
}
|
||
|
internal void Init()
|
||
|
{
|
||
|
base.Begin();
|
||
|
for (int i = 0; i < base.Count; i++)
|
||
|
{
|
||
8 years ago
|
Q1();
|
||
8 years ago
|
Q2();
|
||
|
}
|
||
|
base.End("Method Test");
|
||
|
}
|
||
|
|
||
8 years ago
|
public void Q1()
|
||
|
{
|
||
|
using (var db = GetInstance())
|
||
|
{
|
||
|
var list = db.Queryable<Student, School>((st, sc) => new object[] {
|
||
|
JoinType.Left,st.SchoolId==sc.Id
|
||
|
}).Where(st => st.Id > 0).Select<Student>("*").ToList();
|
||
|
}
|
||
|
}
|
||
8 years ago
|
public void Q2()
|
||
|
{
|
||
8 years ago
|
using (var db = GetInstance())
|
||
|
{
|
||
|
var list = db.Queryable<Student, School>((st, sc) => new object[] {
|
||
|
JoinType.Left,st.SchoolId==sc.Id
|
||
8 years ago
|
}).Where(st=>st.Id>0).Select<Student>("*").ToList();
|
||
8 years ago
|
}
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
|
||
|
public SqlSugarClient GetInstance()
|
||
|
{
|
||
|
SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer });
|
||
8 years ago
|
db.Database.IsEnableLogEvent = true;
|
||
|
db.Database.LogEventStarting = (sql, pars) =>
|
||
|
{
|
||
|
Console.WriteLine(sql+" "+pars);
|
||
|
};
|
||
8 years ago
|
return db;
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
|
}
|