mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update Select(exp,true)
This commit is contained in:
parent
0dbda50d77
commit
74ab60d7ce
@ -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;
|
||||
|
@ -958,6 +958,24 @@ 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 ps = this.Clone().Select(expression).QueryBuilder;
|
||||
var sql = ps.GetSelectValue;
|
||||
if (string.IsNullOrEmpty(sql) || sql.Trim() == "*")
|
||||
{
|
||||
return this.Select<TResult>(expression);
|
||||
}
|
||||
if (ps.Parameters != null && ps.Parameters.Any())
|
||||
{
|
||||
this.QueryBuilder.Parameters.AddRange(ps.Parameters);
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += ps.Parameters.Count;
|
||||
}
|
||||
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>()
|
||||
{
|
||||
|
@ -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…
Reference in New Issue
Block a user