2017-01-14 23:10:36 +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;
|
|
|
|
|
|
2017-03-04 15:07:58 +08:00
|
|
|
|
namespace OrmTest.UnitTest
|
2017-01-14 23:10:36 +08:00
|
|
|
|
{
|
2017-05-16 13:55:57 +08:00
|
|
|
|
public class Field : UnitTestBase
|
2017-01-14 23:10:36 +08:00
|
|
|
|
{
|
2017-01-28 14:32:06 +08:00
|
|
|
|
private Field() { }
|
|
|
|
|
public Field(int eachCount)
|
2017-01-14 23:10:36 +08:00
|
|
|
|
{
|
2017-01-28 14:32:06 +08:00
|
|
|
|
this.Count = eachCount;
|
2017-01-14 23:21:25 +08:00
|
|
|
|
}
|
2017-01-28 14:32:06 +08:00
|
|
|
|
internal void Init()
|
|
|
|
|
{
|
|
|
|
|
base.Begin();
|
|
|
|
|
for (int i = 0; i < base.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
FieldSingle();
|
|
|
|
|
FieldMultiple();
|
|
|
|
|
}
|
|
|
|
|
base.End("Filed Test");
|
|
|
|
|
}
|
|
|
|
|
private void FieldSingle()
|
2017-01-14 23:21:25 +08:00
|
|
|
|
{
|
|
|
|
|
Expression<Func<Student, object>> exp = it => it.Name;
|
2017-03-13 10:55:22 +08:00
|
|
|
|
ExpressionContext expContext = GetContext();
|
2017-02-26 23:56:28 +08:00
|
|
|
|
expContext.Resolve(exp, ResolveExpressType.FieldSingle);
|
2017-01-14 23:21:25 +08:00
|
|
|
|
var selectorValue = expContext.Result.GetString();
|
2017-05-28 19:45:37 +08:00
|
|
|
|
Check(selectorValue, null, expContext.GetTranslationColumnName("Name"), null, "FieldSingle error");
|
2017-01-14 23:21:25 +08:00
|
|
|
|
}
|
2017-01-28 14:32:06 +08:00
|
|
|
|
private void FieldMultiple()
|
2017-01-14 23:21:25 +08:00
|
|
|
|
{
|
|
|
|
|
Expression<Func<Student, object>> exp = it => it.Name;
|
2017-03-13 10:55:22 +08:00
|
|
|
|
ExpressionContext expContext = GetContext();
|
2017-02-26 23:56:28 +08:00
|
|
|
|
expContext.Resolve(exp, ResolveExpressType.FieldMultiple);
|
2017-01-14 23:10:36 +08:00
|
|
|
|
var selectorValue = expContext.Result.GetString();
|
2017-05-28 19:45:37 +08:00
|
|
|
|
Check(selectorValue, null, expContext.GetTranslationColumnName("it.Name"), null, "FieldMultiple error");
|
2017-03-13 10:55:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ExpressionContext GetContext()
|
|
|
|
|
{
|
|
|
|
|
return new SqlServerExpressionContext();//可以更换
|
2017-01-14 23:10:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|