Browse Source

Synchronization code

pull/27/head
sunkaixuan 2 years ago
parent
commit
bd4b83d821
  1. 14
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs
  2. 17
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  3. 20
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs
  4. 25
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs
  5. 10
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs
  6. 1
      Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

14
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs

@ -878,6 +878,20 @@ namespace SqlSugar
#endregion
#region Other
protected string AppendSelect(List<EntityColumnInfo> entityColumnInfos,string sql, ReadOnlyCollection<ParameterExpression> parameters, List<EntityColumnInfo> columnsResult, int parameterIndex1)
{
var columns = entityColumnInfos;
var parameterName = parameters[parameterIndex1];
foreach (var item in columns)
{
if (item.IsIgnore == false && columnsResult.Any(it => it.PropertyName.EqualCase(item.PropertyName)) && !sql.ToLower().Contains(SqlBuilder.GetTranslationColumnName(item.PropertyName.ToLower())))
{
sql = $" {sql},{SqlBuilder.GetTranslationColumnName(item.DbColumnName)} AS {SqlBuilder.GetTranslationColumnName(item.PropertyName)} ";
}
}
return sql;
}
protected string AppendSelect<EntityType>(string sql, ReadOnlyCollection<ParameterExpression> parameters, List<EntityColumnInfo> columnsResult, int parameterIndex1)
{
var columns = this.Context.EntityMaintenance.GetEntityInfo<EntityType>().Columns;

17
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -958,6 +958,23 @@ namespace SqlSugar
Check.ExceptionEasy(this.QueryBuilder.Includes.HasValue(), $"use Includes(...).ToList(it=>new {typeof(TResult).Name} {{...}} )", $"Includes()后面禁使用Select,正确写法: ToList(it=>new {typeof(TResult).Name}{{....}})");
return _Select<TResult>(expression);
}
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression, bool isAutoFill)
{
var clone = this.Clone();
//clone.QueryBuilder.LambdaExpressions.Index = QueryBuilder.LambdaExpressions.Index+1;
var ps = clone.Select(expression).QueryBuilder;
var sql = ps.GetSelectValue;
if (string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = ps.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect(this.EntityInfo.Columns,sql, parameters, columnsResult, 0);
return this.Select<TResult>(sql);
}
public virtual ISugarQueryable<TResult> Select<TResult>()
{

20
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs

@ -195,11 +195,14 @@ namespace SqlSugar
}
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T,T2, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -820,11 +823,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2,T3, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -1336,11 +1342,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex=clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -1983,11 +1992,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4,T5, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);

25
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs

@ -244,11 +244,14 @@ namespace SqlSugar
}
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5,T6, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -868,11 +871,14 @@ namespace SqlSugar
}
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -1460,11 +1466,14 @@ namespace SqlSugar
}
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -1990,11 +1999,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -2567,11 +2579,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);

10
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs

@ -254,11 +254,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);
@ -806,11 +809,14 @@ namespace SqlSugar
#region Select
public ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, TResult>> expression, bool isAutoFill)
{
var sql = this.Clone().Select(expression).QueryBuilder.GetSelectValue;
var clone = this.Clone().Select(expression);
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.LambdaExpressions.ParameterIndex = clone.QueryBuilder.LambdaExpressions.ParameterIndex;
var parameters = (expression as LambdaExpression).Parameters;
var columnsResult = this.Context.EntityMaintenance.GetEntityInfo<TResult>().Columns;
sql = AppendSelect<T>(sql, parameters, columnsResult, 0);

1
Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

@ -122,6 +122,7 @@ namespace SqlSugar
Task<bool> AnyAsync();
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression,bool isAutoFill);
ISugarQueryable<TResult> Select<TResult>();
ISugarQueryable<TResult> Select<TResult>(string select);
ISugarQueryable<T> Select(string select);

Loading…
Cancel
Save