This commit is contained in:
sunkaixuan
2017-04-26 02:42:26 +08:00
parent 51c10cb80a
commit b5557e6cbb
6 changed files with 31 additions and 2 deletions

View File

@@ -39,7 +39,12 @@ namespace OrmTest.UnitTest
#region dr ot entity
db.IgnoreComumns.Add("TestId", "Student");
var d5 = db.Queryable<Student>().ToList();
var d51 = db.Queryable<Student>().GroupBy(it=>it.Id).OrderBy(it=>it.Id).Select(it=>it.Id).ToSql();
var gos = db.Queryable<Student>()
.With(SqlWith.NoLock)
.GroupBy(it=>it.Id)
.OrderBy(it=>it.Id)
.Select(it=>it.Id).ToSql();
base.Check("SELECT [Id] FROM [Student] WITH(NOLOCK) GROUP BY [Id] ORDER BY [Id] ASC", null, gos.Key,null, "基本查询出错");
var dr3 = db.Queryable<Student>().Select(it => new ViewModelStudent2 { Name=it.Name,Student=it}).ToList();
var dr0 = db.Queryable<Student>().Select(it => new { id=it.Id,w=new { x=it } }).ToList();
var dr1 = db.Queryable<Student>().Select(it => new { newid = it.Id }).ToList();

View File

@@ -436,6 +436,12 @@ namespace SqlSugar
GroupBy(orderByValue.GetResultString());
return this;
}
public ISugarQueryable<T> With(string withString)
{
SqlBuilder.LambadaQueryBuilder.TableWithString = withString;
return this;
}
#endregion
}
}

View File

@@ -217,7 +217,10 @@ namespace SqlSugar
{
get
{
var result = Builder.GetTranslationTableName(EntityName) + TableWithString;
var result = Builder.GetTranslationTableName(EntityName);
if (this.TableWithString.IsValuable()) {
result += " " + TableWithString;
}
if (this.TableShortName.IsValuable())
{
result += " " + TableShortName;

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class SqlWith
{
public const string NoLock = "WITH(NOLOCK) ";
}
}

View File

@@ -12,6 +12,7 @@ namespace SqlSugar
SqlSugarClient Context { get; set; }
ISqlBuilder SqlBuilder { get; set; }
ISugarQueryable<T> With(string withString);
ISugarQueryable<T> AddParameters(object pars);
ISugarQueryable<T> AddParameters(SugarParameter[] pars);
ISugarQueryable<T> AddJoinInfo(string tableName, string shortName, string joinWhere, JoinType type=JoinType.Left);

View File

@@ -89,6 +89,7 @@
<Compile Include="Entities\DbColumnInfo.cs" />
<Compile Include="Entities\DbTableInfo.cs" />
<Compile Include="Entities\Mapping\IgnoreComumn.cs" />
<Compile Include="Entities\SqlWith.cs" />
<Compile Include="ExpressionsToSql\Common\CommonTempDataType.cs" />
<Compile Include="ExpressionsToSql\Common\MethodCallExpressionModel.cs" />
<Compile Include="ExpressionsToSql\Method\DefaultDbMethod.cs" />