string query1String, query2String;
//Linq查询
using (var context = new TestDB()) {
var result = context.Users.Where(c => c.Name == "admin");
query1String = result.Expression.ToString();
}
//Lambda查询
using (var context = new TestDB()) {
var result = from c in context.Users
where c.Name == "admin"
select c;
query2String = result.Expression.ToString();
}
//混合查询
using (var context = new TestDB()) {
var result = (from c in context.Users
where c.Name == "admin"
select c.Age).Max();
}
Assert.AreEqual(query1String, query2String);