mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
-
This commit is contained in:
@@ -95,17 +95,17 @@ namespace OrmTest.Demo
|
||||
var db = GetInstance();
|
||||
var list = db.Queryable<Student>()
|
||||
.GroupBy(it => it.Name)
|
||||
.GroupBy(it => it.Id).Having(it => NBORM.AggregateAvg(it.Id) > 0)
|
||||
.Select(it => new { idAvg = NBORM.AggregateAvg(it.Id), name = it.Name }).ToList();
|
||||
.GroupBy(it => it.Id).Having(it => SqlFunc.AggregateAvg(it.Id) > 0)
|
||||
.Select(it => new { idAvg = SqlFunc.AggregateAvg(it.Id), name = it.Name }).ToList();
|
||||
|
||||
//SQL:
|
||||
//SELECT AVG([Id]) AS[idAvg], [Name] AS[name] FROM[Student] GROUP BY[Name],[Id] HAVING(AVG([Id]) > 0 )
|
||||
|
||||
//NBORM.AggregateSum(object thisValue)
|
||||
//NBORM.AggregateAvg<TResult>(TResult thisValue)
|
||||
//NBORM.AggregateMin(object thisValue)
|
||||
//NBORM.AggregateMax(object thisValue)
|
||||
//NBORM.AggregateCount(object thisValue)
|
||||
//SqlFunc.AggregateSum(object thisValue)
|
||||
//SqlFunc.AggregateAvg<TResult>(TResult thisValue)
|
||||
//SqlFunc.AggregateMin(object thisValue)
|
||||
//SqlFunc.AggregateMax(object thisValue)
|
||||
//SqlFunc.AggregateCount(object thisValue)
|
||||
}
|
||||
|
||||
private static void Ado()
|
||||
@@ -125,7 +125,7 @@ namespace OrmTest.Demo
|
||||
var getAllNoLock = db.Queryable<Student>().With(SqlWith.NoLock).ToList();
|
||||
var getByPrimaryKey = db.Queryable<Student>().InSingle(2);
|
||||
var getByWhere = db.Queryable<Student>().Where(it => it.Id == 1 || it.Name == "a").ToList();
|
||||
var getByFuns = db.Queryable<Student>().Where(it => NBORM.IsNullOrEmpty(it.Name)).ToList();
|
||||
var getByFuns = db.Queryable<Student>().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList();
|
||||
var sum = db.Queryable<Student>().Sum(it => it.Id);
|
||||
var isAny = db.Queryable<Student>().Where(it => it.Id == -1).Any();
|
||||
var isAny2 = db.Queryable<Student>().Any(it => it.Id == -1);
|
||||
@@ -133,14 +133,14 @@ namespace OrmTest.Demo
|
||||
var in1 = db.Queryable<Student>().In(it=>it.Id,new int[] { 1, 2, 3 }).ToList();
|
||||
var in2 = db.Queryable<Student>().In(new int[] { 1, 2, 3 }).ToList();
|
||||
int[] array = new int[] { 1, 2 };
|
||||
var in3 = db.Queryable<Student>().Where(it=>NBORM.ContainsArray(array, it.Id)).ToList();
|
||||
var in3 = db.Queryable<Student>().Where(it=>SqlFunc.ContainsArray(array, it.Id)).ToList();
|
||||
var group = db.Queryable<Student>().GroupBy(it => it.Id)
|
||||
.Having(it => NBORM.AggregateCount(it.Id) > 10)
|
||||
.Select(it => new { id = NBORM.AggregateCount(it.Id) }).ToList();
|
||||
.Having(it => SqlFunc.AggregateCount(it.Id) > 10)
|
||||
.Select(it => new { id = SqlFunc.AggregateCount(it.Id) }).ToList();
|
||||
|
||||
var between = db.Queryable<Student>().Where(it => NBORM.Between(it.Id, 1, 20)).ToList();
|
||||
var between = db.Queryable<Student>().Where(it => SqlFunc.Between(it.Id, 1, 20)).ToList();
|
||||
|
||||
var getTodayList = db.Queryable<Student>().Where(it => NBORM.DateIsSame(it.CreateTime, DateTime.Now)).ToList();
|
||||
var getTodayList = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(it.CreateTime, DateTime.Now)).ToList();
|
||||
}
|
||||
|
||||
public static void Page()
|
||||
@@ -218,41 +218,41 @@ namespace OrmTest.Demo
|
||||
public static void Funs()
|
||||
{
|
||||
var db = GetInstance();
|
||||
var t1 = db.Queryable<Student>().Where(it => NBORM.ToLower(it.Name) == NBORM.ToLower("JACK")).ToList();
|
||||
var t1 = db.Queryable<Student>().Where(it => SqlFunc.ToLower(it.Name) == SqlFunc.ToLower("JACK")).ToList();
|
||||
//SELECT [Id],[SchoolId],[Name],[CreateTime] FROM [Student] WHERE ((LOWER([Name])) = (LOWER(@MethodConst0)) )
|
||||
|
||||
/***More Functions***/
|
||||
//NBORM.IsNullOrEmpty(object thisValue)
|
||||
//NBORM.ToLower(object thisValue)
|
||||
//NBORM.string ToUpper(object thisValue)
|
||||
//NBORM.string Trim(object thisValue)
|
||||
//NBORM.bool Contains(string thisValue, string parameterValue)
|
||||
//NBORM.ContainsArray(object[] thisValue, string parameterValue)
|
||||
//NBORM.StartsWith(object thisValue, string parameterValue)
|
||||
//NBORM.EndsWith(object thisValue, string parameterValue)
|
||||
//NBORM.Equals(object thisValue, object parameterValue)
|
||||
//NBORM.DateIsSame(DateTime date1, DateTime date2)
|
||||
//NBORM.DateIsSame(DateTime date1, DateTime date2, DateType dataType)
|
||||
//NBORM.DateAdd(DateTime date, int addValue, DateType millisecond)
|
||||
//NBORM.DateAdd(DateTime date, int addValue)
|
||||
//NBORM.DateValue(DateTime date, DateType dataType)
|
||||
//NBORM.Between(object value, object start, object end)
|
||||
//NBORM.ToInt32(object value)
|
||||
//NBORM.ToInt64(object value)
|
||||
//NBORM.ToDate(object value)
|
||||
//NBORM.ToString(object value)
|
||||
//NBORM.ToDecimal(object value)
|
||||
//NBORM.ToGuid(object value)
|
||||
//NBORM.ToDouble(object value)
|
||||
//NBORM.ToBool(object value)
|
||||
//NBORM.Substring(object value, int index, int length)
|
||||
//NBORM.Replace(object value, string oldChar, string newChar)
|
||||
//NBORM.Length(object value) { throw new NotImplementedException(); }
|
||||
//NBORM.AggregateSum(object thisValue)
|
||||
//NBORM.AggregateAvg<TResult>(TResult thisValue)
|
||||
//NBORM.AggregateMin(object thisValue)
|
||||
//NBORM.AggregateMax(object thisValue)
|
||||
//NBORM.AggregateCount(object thisValue)
|
||||
//SqlFunc.IsNullOrEmpty(object thisValue)
|
||||
//SqlFunc.ToLower(object thisValue)
|
||||
//SqlFunc.string ToUpper(object thisValue)
|
||||
//SqlFunc.string Trim(object thisValue)
|
||||
//SqlFunc.bool Contains(string thisValue, string parameterValue)
|
||||
//SqlFunc.ContainsArray(object[] thisValue, string parameterValue)
|
||||
//SqlFunc.StartsWith(object thisValue, string parameterValue)
|
||||
//SqlFunc.EndsWith(object thisValue, string parameterValue)
|
||||
//SqlFunc.Equals(object thisValue, object parameterValue)
|
||||
//SqlFunc.DateIsSame(DateTime date1, DateTime date2)
|
||||
//SqlFunc.DateIsSame(DateTime date1, DateTime date2, DateType dataType)
|
||||
//SqlFunc.DateAdd(DateTime date, int addValue, DateType millisecond)
|
||||
//SqlFunc.DateAdd(DateTime date, int addValue)
|
||||
//SqlFunc.DateValue(DateTime date, DateType dataType)
|
||||
//SqlFunc.Between(object value, object start, object end)
|
||||
//SqlFunc.ToInt32(object value)
|
||||
//SqlFunc.ToInt64(object value)
|
||||
//SqlFunc.ToDate(object value)
|
||||
//SqlFunc.ToString(object value)
|
||||
//SqlFunc.ToDecimal(object value)
|
||||
//SqlFunc.ToGuid(object value)
|
||||
//SqlFunc.ToDouble(object value)
|
||||
//SqlFunc.ToBool(object value)
|
||||
//SqlFunc.Substring(object value, int index, int length)
|
||||
//SqlFunc.Replace(object value, string oldChar, string newChar)
|
||||
//SqlFunc.Length(object value) { throw new NotImplementedException(); }
|
||||
//SqlFunc.AggregateSum(object thisValue)
|
||||
//SqlFunc.AggregateAvg<TResult>(TResult thisValue)
|
||||
//SqlFunc.AggregateMin(object thisValue)
|
||||
//SqlFunc.AggregateMax(object thisValue)
|
||||
//SqlFunc.AggregateCount(object thisValue)
|
||||
}
|
||||
public static void Select()
|
||||
{
|
||||
|
@@ -59,7 +59,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
private void Length()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Length("aaaa") >1;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Length("aaaa") >1;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -72,7 +72,7 @@ namespace OrmTest.UnitTest
|
||||
private void Replace()
|
||||
{
|
||||
var x2 = Guid.NewGuid();
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Replace("aaaa","a", "1") == "a";
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Replace("aaaa","a", "1") == "a";
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -85,7 +85,7 @@ namespace OrmTest.UnitTest
|
||||
private void Substring()
|
||||
{
|
||||
var x2 = Guid.NewGuid();
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Substring("aaaa",0,2) == "a";
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Substring("aaaa",0,2) == "a";
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -98,7 +98,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToBool()
|
||||
{
|
||||
var x2 = Guid.NewGuid();
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToBool("true") == true;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToBool("true") == true;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -111,7 +111,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToDouble()
|
||||
{
|
||||
var x2 = Guid.NewGuid();
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToDouble("2") == 2;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToDouble("2") == 2;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -124,7 +124,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToGuid()
|
||||
{
|
||||
var x2 = Guid.NewGuid();
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToGuid("A94027A3-476E-478D-8228-F4054394B874") == x2;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToGuid("A94027A3-476E-478D-8228-F4054394B874") == x2;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -137,7 +137,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToDecimal()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToDecimal("22") == 1;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToDecimal("22") == 1;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -150,7 +150,7 @@ namespace OrmTest.UnitTest
|
||||
private void Tostring()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToString("2015-1-1") == "a";
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToString("2015-1-1") == "a";
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -163,7 +163,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToDate()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToDate("2015-1-1") == x2;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToDate("2015-1-1") == x2;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -176,7 +176,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToInt64()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToInt64("3") == 1;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToInt64("3") == 1;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -189,7 +189,7 @@ namespace OrmTest.UnitTest
|
||||
private void ToInt32()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ToInt32("3")== 1;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ToInt32("3")== 1;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -202,7 +202,7 @@ namespace OrmTest.UnitTest
|
||||
private void DateValue()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.DateValue(x2,DateType.Year)==1;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.DateValue(x2,DateType.Year)==1;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -214,7 +214,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
private void StartsWith()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.StartsWith(it.Name, "a");
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.StartsWith(it.Name, "a");
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -225,7 +225,7 @@ namespace OrmTest.UnitTest
|
||||
}
|
||||
private void EndsWith()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.EndsWith(it.Name, "a");
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.EndsWith(it.Name, "a");
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -236,7 +236,7 @@ namespace OrmTest.UnitTest
|
||||
}
|
||||
private void Between()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Between(it.Name,1, 2);
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Between(it.Name,1, 2);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -249,7 +249,7 @@ namespace OrmTest.UnitTest
|
||||
private void DateAddByType()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.DateAdd(x2, 11, DateType.Millisecond)==x2;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.DateAdd(x2, 11, DateType.Millisecond)==x2;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -262,7 +262,7 @@ namespace OrmTest.UnitTest
|
||||
private void DateAddDay()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.DateAdd(x2, 1)==x2;
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.DateAdd(x2, 1)==x2;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -275,7 +275,7 @@ namespace OrmTest.UnitTest
|
||||
private void DateIsSameByType()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.DateIsSame(x2,x2, DateType.Millisecond);
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.DateIsSame(x2,x2, DateType.Millisecond);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -288,7 +288,7 @@ namespace OrmTest.UnitTest
|
||||
private void DateIsSameByDay()
|
||||
{
|
||||
var x2 = DateTime.Now;
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.DateIsSame(x2,x2);
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.DateIsSame(x2,x2);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -300,7 +300,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
private void Equals()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Equals(it.Name, "a");
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Equals(it.Name, "a");
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -310,7 +310,7 @@ namespace OrmTest.UnitTest
|
||||
}, "Equals1 error");
|
||||
|
||||
|
||||
Expression<Func<Student, bool>> exp2 = it => NBORM.Equals("a",it.Name);
|
||||
Expression<Func<Student, bool>> exp2 = it => SqlFunc.Equals("a",it.Name);
|
||||
SqlServerExpressionContext expContext2 = new SqlServerExpressionContext();
|
||||
expContext2.Resolve(exp2, ResolveExpressType.WhereSingle);
|
||||
var value2 = expContext2.Result.GetString();
|
||||
@@ -321,7 +321,7 @@ namespace OrmTest.UnitTest
|
||||
}
|
||||
private void Equals_2()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Equals(it.Name, it.Name);
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Equals(it.Name, it.Name);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -331,7 +331,7 @@ namespace OrmTest.UnitTest
|
||||
}, "Equals1 error");
|
||||
|
||||
|
||||
Expression<Func<Student, bool>> exp2 = it => NBORM.Equals("a", "a2");
|
||||
Expression<Func<Student, bool>> exp2 = it => SqlFunc.Equals("a", "a2");
|
||||
SqlServerExpressionContext expContext2 = new SqlServerExpressionContext();
|
||||
expContext2.Resolve(exp2, ResolveExpressType.WhereSingle);
|
||||
var value2 = expContext2.Result.GetString();
|
||||
@@ -343,7 +343,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
private void Contains()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.Contains(it.Name, "a");
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.Contains(it.Name, "a");
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -356,7 +356,7 @@ namespace OrmTest.UnitTest
|
||||
private void ContainsArray()
|
||||
{
|
||||
string[] array = new string[] { "1","2"};
|
||||
Expression<Func<Student, bool>> exp = it => NBORM.ContainsArray(array, it.Name);
|
||||
Expression<Func<Student, bool>> exp = it => SqlFunc.ContainsArray(array, it.Name);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -366,7 +366,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
private void Trim()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it =>NBORM.Trim(" a")==it.Name;
|
||||
Expression<Func<Student, bool>> exp = it =>SqlFunc.Trim(" a")==it.Name;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -378,7 +378,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
private void ToUpper()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it =>"a"== NBORM.ToUpper(it.Id) ;
|
||||
Expression<Func<Student, bool>> exp = it =>"a"== SqlFunc.ToUpper(it.Id) ;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -389,7 +389,7 @@ namespace OrmTest.UnitTest
|
||||
}
|
||||
private void ToLower()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => "a" == NBORM.ToLower(it.Id);
|
||||
Expression<Func<Student, bool>> exp = it => "a" == SqlFunc.ToLower(it.Id);
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -402,7 +402,7 @@ namespace OrmTest.UnitTest
|
||||
#region StringIsNullOrEmpty
|
||||
private void StringIsNullOrEmpty()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => it.Id > 2 || NBORM.IsNullOrEmpty(it.Id); ;
|
||||
Expression<Func<Student, bool>> exp = it => it.Id > 2 || SqlFunc.IsNullOrEmpty(it.Id); ;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -413,7 +413,7 @@ namespace OrmTest.UnitTest
|
||||
}
|
||||
private void StringIsNullOrEmpty2()
|
||||
{
|
||||
Expression<Func<Student, bool>> exp = it => 2 == it.Id || NBORM.IsNullOrEmpty(true); ;
|
||||
Expression<Func<Student, bool>> exp = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(true); ;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -426,7 +426,7 @@ namespace OrmTest.UnitTest
|
||||
private void StringIsNullOrEmpty3()
|
||||
{
|
||||
int a = 1;
|
||||
Expression<Func<Student, bool>> exp = it => 2 == it.Id || NBORM.IsNullOrEmpty(a); ;
|
||||
Expression<Func<Student, bool>> exp = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(a); ;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
@@ -439,7 +439,7 @@ namespace OrmTest.UnitTest
|
||||
private void StringIsNullOrEmpty4()
|
||||
{
|
||||
WhereConst.name = "xx";
|
||||
Expression<Func<Student, bool>> exp = it => 2 == it.Id || NBORM.IsNullOrEmpty(WhereConst.name); ;
|
||||
Expression<Func<Student, bool>> exp = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(WhereConst.name); ;
|
||||
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
|
||||
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
|
||||
var value = expContext.Result.GetString();
|
||||
|
@@ -49,7 +49,7 @@ namespace OrmTest.UnitTest
|
||||
#region sql and parameters validate
|
||||
var t1 = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||
JoinType.Inner,st.Id==sc.Id
|
||||
}).GroupBy(st => st.Id).Having(st => NBORM.AggregateAvg(st.Id) == 1).Select(st => new { avgId = NBORM.AggregateAvg(st.Id) }).ToSql();
|
||||
}).GroupBy(st => st.Id).Having(st => SqlFunc.AggregateAvg(st.Id) == 1).Select(st => new { avgId = SqlFunc.AggregateAvg(st.Id) }).ToSql();
|
||||
base.Check("SELECT AVG([st].[ID]) AS [avgId] FROM [STudent] st Inner JOIN School sc ON ( [st].[ID] = [sc].[Id] ) GROUP BY [st].[ID] HAVING (AVG([st].[ID]) = @Const0 ) ",
|
||||
new List<SugarParameter>() {
|
||||
new SugarParameter("@Const0",1)
|
||||
|
@@ -102,7 +102,7 @@ namespace OrmTest.UnitTest
|
||||
|
||||
var t8 = db.Queryable<Student>()
|
||||
.Where(it=>it.Id==1)
|
||||
.WhereIF(true,it=> NBORM.Contains(it.Name,"a"))
|
||||
.WhereIF(true,it=> SqlFunc.Contains(it.Name,"a"))
|
||||
.OrderBy(it => it.Id, OrderByType.Desc).Skip((pageIndex - 1) * pageSize).Take(pageSize * pageIndex).With(SqlWith.NoLock).ToSql();
|
||||
base.Check(@"WITH PageTable AS(
|
||||
SELECT [ID],[SchoolId],[Name],[CreateTime] FROM [STudent] WITH(NOLOCK) WHERE ( [ID] = @Id0 ) AND ([Name] like '%'+@MethodConst1+'%')
|
||||
|
Reference in New Issue
Block a user