mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Synchronization code
This commit is contained in:
parent
39cbe9cb06
commit
dcd7bd7e7e
@ -326,6 +326,10 @@ namespace SqlSugar
|
||||
{
|
||||
navPkColumn = navEntityInfo.Columns.Where(it => it.PropertyName== navObjectNameColumnInfo.Navigat.Name2).FirstOrDefault();
|
||||
}
|
||||
if (navPkColumn == null && navType.FullName.IsCollectionsList())
|
||||
{
|
||||
Check.ExceptionEasy($"{navObjectNamePropety.Name} type error ", $"一对一不能是List对象 {navObjectNamePropety.Name} ");
|
||||
}
|
||||
var ids = list.Select(it => it.GetType().GetProperty(navObjectNameColumnInfo.Navigat.Name).GetValue(it)).Select(it => it == null ? "null" : it).Distinct().ToList();
|
||||
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
||||
conditionalModels.Add((new ConditionalModel()
|
||||
|
@ -942,9 +942,19 @@ namespace SqlSugar
|
||||
{
|
||||
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + this.QueryBuilder.AsTables.First().Value + $" {SqlWith.NoLock} )";
|
||||
}
|
||||
else if (this.QueryBuilder.IsSqlQuery && this.QueryBuilder.AsTables.First().Value.ObjToString().StartsWith("("))
|
||||
{
|
||||
var tableName = this.QueryBuilder.AsTables.First().Value;
|
||||
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + tableName + ")" + this.QueryBuilder.TableShortName;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + this.QueryBuilder.AsTables.First().Value + ")";
|
||||
var tableName = this.QueryBuilder.AsTables.First().Value;
|
||||
if (tableName != null && Regex.IsMatch(tableName, @"^\w+$"))
|
||||
{
|
||||
tableName = SqlBuilder.GetTranslationTableName(tableName);
|
||||
}
|
||||
this.QueryBuilder.AsTables[tableinfo.Key] = " (SELECT * FROM " + tableName + ")";
|
||||
}
|
||||
this.QueryBuilder.SelectValue = this.QueryBuilder.TableShortName + ".*";
|
||||
}
|
||||
@ -1575,5 +1585,17 @@ namespace SqlSugar
|
||||
return this.Context.Ado.SqlQuery<Type>(sql,parameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Bool
|
||||
|
||||
private bool MasterHasWhereFirstJoin()
|
||||
{
|
||||
return this.QueryBuilder.JoinIndex == 0 &&
|
||||
this.QueryBuilder.IsSqlQuery == false &&
|
||||
!this.QueryBuilder.AsTables.Any() &&
|
||||
this.QueryBuilder.IsSingle() &&
|
||||
this.QueryBuilder.WhereInfos.Any();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,11 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T, T2> LeftJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
if (MasterHasWhereFirstJoin())
|
||||
{
|
||||
return this.MergeTable().LeftJoin<T2>(joinExpression);
|
||||
}
|
||||
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
@ -126,6 +131,11 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T, T2> FullJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
if (MasterHasWhereFirstJoin())
|
||||
{
|
||||
return this.MergeTable().FullJoin<T2>(joinExpression);
|
||||
}
|
||||
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
@ -135,6 +145,12 @@ namespace SqlSugar
|
||||
}
|
||||
public ISugarQueryable<T, T2> RightJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
|
||||
if (MasterHasWhereFirstJoin())
|
||||
{
|
||||
return this.MergeTable().RightJoin<T2>(joinExpression);
|
||||
}
|
||||
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
@ -143,8 +159,14 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
public ISugarQueryable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
|
||||
if (MasterHasWhereFirstJoin())
|
||||
{
|
||||
return this.MergeTable().InnerJoin<T2>(joinExpression);
|
||||
}
|
||||
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
@ -152,6 +174,7 @@ namespace SqlSugar
|
||||
result.QueryBuilder.JoinQueryInfos.Add(GetJoinInfo(joinExpression, JoinType.Inner));
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
QueryBuilder.Clear();
|
||||
|
@ -181,7 +181,7 @@ namespace SqlSugar
|
||||
|
||||
protected override string IsAnyTableRemarkSql { get { throw new NotSupportedException(); } }
|
||||
|
||||
protected override string RenameTableSql => "alter table 表名 {0} to {1}";
|
||||
protected override string RenameTableSql => "alter table {0} to {1}";
|
||||
|
||||
protected override string CreateIndexSql
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user