mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
Multi-table query AS (Tablename) automatic NOLOCK
This commit is contained in:
parent
6dbf35ce4f
commit
193ac3169d
@ -274,6 +274,15 @@ namespace OrmTest
|
|||||||
|
|
||||||
.Where((o) => o.Id > 0)
|
.Where((o) => o.Id > 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
var db = Db;
|
||||||
|
db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings
|
||||||
|
{
|
||||||
|
IsWithNoLockQuery = true,
|
||||||
|
};
|
||||||
|
var sql13 = db.Queryable<Order>().AS("[ORDER]")
|
||||||
|
.LeftJoin<OrderItem>((o,i) => o.Id == i.OrderId).AS<OrderItem>("[ORDERDETAIL]")
|
||||||
|
.LeftJoin<Custom>((o, i, c) => c.Id == o.CustomId).AS<Custom>("[CUSTOM]")
|
||||||
|
.Select<ViewOrder>().ToList();
|
||||||
}
|
}
|
||||||
public class VUOrder
|
public class VUOrder
|
||||||
{
|
{
|
||||||
|
@ -2421,7 +2421,14 @@ namespace SqlSugar
|
|||||||
if (this.QueryBuilder.AsTables != null && this.QueryBuilder.AsTables.Count==1)
|
if (this.QueryBuilder.AsTables != null && this.QueryBuilder.AsTables.Count==1)
|
||||||
{
|
{
|
||||||
var tableinfo = this.QueryBuilder.AsTables.First();
|
var tableinfo = this.QueryBuilder.AsTables.First();
|
||||||
|
if (this.Context.CurrentConnectionConfig?.MoreSettings?.IsWithNoLockQuery == true)
|
||||||
|
{
|
||||||
|
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + this.QueryBuilder.AsTables.First().Value + $" {SqlWith.NoLock} )";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + this.QueryBuilder.AsTables.First().Value + ")";
|
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + this.QueryBuilder.AsTables.First().Value + ")";
|
||||||
|
}
|
||||||
this.QueryBuilder.SelectValue = this.QueryBuilder.TableShortName +".*";
|
this.QueryBuilder.SelectValue = this.QueryBuilder.TableShortName +".*";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -675,9 +675,12 @@ namespace SqlSugar
|
|||||||
result += (TableShortName + UtilConstants.Space);
|
result += (TableShortName + UtilConstants.Space);
|
||||||
}
|
}
|
||||||
if (this.TableWithString.HasValue() && this.TableWithString != SqlWith.Null)
|
if (this.TableWithString.HasValue() && this.TableWithString != SqlWith.Null)
|
||||||
|
{
|
||||||
|
if (!result.TrimStart().StartsWith("("))
|
||||||
{
|
{
|
||||||
result += TableWithString + UtilConstants.Space;
|
result += TableWithString + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!this.IsSingle())
|
if (!this.IsSingle())
|
||||||
{
|
{
|
||||||
result += GetJoinValueString + UtilConstants.Space;
|
result += GetJoinValueString + UtilConstants.Space;
|
||||||
|
Loading…
Reference in New Issue
Block a user