This commit is contained in:
sunkaixuan 2017-09-20 12:56:54 +08:00
parent c116a49b99
commit ae879c3259
3 changed files with 46 additions and 1 deletions

View File

@ -15,7 +15,7 @@ namespace OrmTest.Models
public int Id { get; set; }
public int? SchoolId { get; set; }
public string Name { get; set; }
public DateTimeOffset? CreateTime { get; set; }
public DateTime? CreateTime { get; set; }
[SugarColumn(IsIgnore=true)]
public int TestId { get; set; }
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace SqlSugar
{
public class SubOrderBy : ISubOperation
{
public string Name
{
get { return "OrderBy"; }
}
public Expression Expression
{
get; set;
}
public int Sort
{
get
{
return 480;
}
}
public ExpressionContext Context
{
get; set;
}
public string GetValue(Expression expression)
{
var exp = expression as MethodCallExpression;
var argExp = exp.Arguments[0];
var result = "ORDER BY " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.FieldSingle);
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
result = result.Replace(selfParameterName, string.Empty);
return result;
}
}
}

View File

@ -82,6 +82,7 @@
<Compile Include="ExpressionsToSql\Subquery\Items\SubBegin.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubMin.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubMax.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubOrderBy.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubRightBracket.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubSelect.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubSelectDefault.cs" />