mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +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)
|
||||
.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
|
||||
{
|
||||
|
@ -2421,7 +2421,14 @@ namespace SqlSugar
|
||||
if (this.QueryBuilder.AsTables != null && this.QueryBuilder.AsTables.Count==1)
|
||||
{
|
||||
var tableinfo = this.QueryBuilder.AsTables.First();
|
||||
this.QueryBuilder.AsTables[tableinfo.Key] =" (SELECT * FROM " +this.QueryBuilder.AsTables.First().Value+")";
|
||||
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.SelectValue = this.QueryBuilder.TableShortName +".*";
|
||||
}
|
||||
}
|
||||
|
@ -676,7 +676,10 @@ namespace SqlSugar
|
||||
}
|
||||
if (this.TableWithString.HasValue() && this.TableWithString != SqlWith.Null)
|
||||
{
|
||||
result += TableWithString + UtilConstants.Space;
|
||||
if (!result.TrimStart().StartsWith("("))
|
||||
{
|
||||
result += TableWithString + UtilConstants.Space;
|
||||
}
|
||||
}
|
||||
if (!this.IsSingle())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user