mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Add Queryable.IgnoreColumns
This commit is contained in:
parent
0a84998755
commit
5c1d4dbc30
@ -50,6 +50,20 @@ namespace SqlSugar
|
||||
{
|
||||
QueryBuilder.Clear();
|
||||
}
|
||||
public ISugarQueryable<T> IgnoreColumns(Expression<Func<T, object>> columns)
|
||||
{
|
||||
var ignoreColumns = QueryBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it).ToLower()).ToList();
|
||||
return IgnoreColumns(ignoreColumns.ToArray());
|
||||
}
|
||||
public ISugarQueryable<T> IgnoreColumns(params string[] columns)
|
||||
{
|
||||
if (QueryBuilder.IgnoreColumns.IsNullOrEmpty())
|
||||
{
|
||||
QueryBuilder.IgnoreColumns = new List<string>();
|
||||
}
|
||||
QueryBuilder.IgnoreColumns.AddRange(columns);
|
||||
return this;
|
||||
}
|
||||
public void AddQueue()
|
||||
{
|
||||
var sqlObj = this.ToSql();
|
||||
@ -1885,6 +1899,7 @@ namespace SqlSugar
|
||||
asyncQueryableBuilder.WhereIndex = this.QueryBuilder.WhereIndex;
|
||||
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
||||
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
asyncQueryableBuilder.IgnoreColumns = this.QueryBuilder.IgnoreColumns;
|
||||
}
|
||||
protected int SetCacheTime(int cacheDurationInSeconds)
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Splicing basic
|
||||
public List<string> IgnoreColumns { get; set; }
|
||||
public bool IsCount { get; set; }
|
||||
public int? Skip { get; set; }
|
||||
public int ExternalPageIndex { get; set; }
|
||||
@ -429,7 +430,12 @@ namespace SqlSugar
|
||||
{
|
||||
pre = Builder.GetTranslationColumnName(TableShortName) + ".";
|
||||
}
|
||||
result = string.Join(",", this.Context.EntityMaintenance.GetEntityInfo(this.EntityType).Columns.Where(it => !it.IsIgnore).Select(it => pre + Builder.GetTranslationColumnName(it.EntityName, it.PropertyName)));
|
||||
var columns = this.Context.EntityMaintenance.GetEntityInfo(this.EntityType).Columns.Where(it => !it.IsIgnore);
|
||||
if (this.IgnoreColumns.HasValue())
|
||||
{
|
||||
columns = columns.Where(c => !this.IgnoreColumns.Any(i=>c.PropertyName.Equals(i,StringComparison.CurrentCultureIgnoreCase)||c.DbColumnName.Equals(i,StringComparison.CurrentCultureIgnoreCase))).ToList();
|
||||
}
|
||||
result = string.Join(",", columns.Select(it => pre + Builder.GetTranslationColumnName(it.EntityName, it.PropertyName)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -152,6 +152,8 @@ namespace SqlSugar
|
||||
string ToClassString(string className);
|
||||
void Clear();
|
||||
void AddQueue();
|
||||
ISugarQueryable<T> IgnoreColumns(Expression<Func<T, object>> columns);
|
||||
ISugarQueryable<T> IgnoreColumns(params string[] columns);
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2> : ISugarQueryable<T>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user