SqlSugar/OrmTest/ExpressionTest/Select.cs

42 lines
1.2 KiB
C#
Raw Normal View History

2017-01-14 15:16:20 +08:00
using OrmTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest.ExpressionTest
{
public class Select
{
internal static void Init()
{
2017-01-14 19:35:22 +08:00
o1();
o2();
}
private static void o1()
{
Expression<Func<Student, object>> exp = it => new Student() { Name = "a", Id=it.Id };
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.WhereSingle);
expContext.ResolveType = ResolveExpressType.SelectSingle;
expContext.Resolve();
var x = expContext.Result.GetString();
var pars = expContext.Parameters;
}
private static void o2()
{
Expression<Func<Student, object>> exp = it =>new { x = "a" };
2017-01-14 15:16:20 +08:00
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.WhereSingle);
expContext.ResolveType = ResolveExpressType.SelectSingle;
2017-01-14 19:15:54 +08:00
expContext.Resolve();
var x = expContext.Result.GetString();
2017-01-14 19:35:22 +08:00
var pars = expContext.Parameters;
2017-01-14 15:16:20 +08:00
}
}
}