Add: SugarColumn(QuerySql=" getdate() ")

This commit is contained in:
sunkaixuan 2023-12-18 13:37:24 +08:00
parent 634020b822
commit 8bddf50c59
4 changed files with 14 additions and 1 deletions

View File

@ -362,6 +362,7 @@ namespace SqlSugar
column.UpdateServerTime= sugarColumn.UpdateServerTime;
column.UpdateSql= sugarColumn.UpdateSql;
column.IsDisabledAlterColumn = sugarColumn.IsDisabledAlterColumn;
column.QuerySql = sugarColumn.QuerySql;
if (sugarColumn.IsJson && String.IsNullOrEmpty(sugarColumn.ColumnDataType))
{
if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL)

View File

@ -907,7 +907,7 @@ namespace SqlSugar
{
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)));
result = string.Join(",", columns.Select(it => GetSelectStringByColumnInfo(it, pre)));
}
else
{
@ -920,6 +920,16 @@ namespace SqlSugar
}
return result;
}
private string GetSelectStringByColumnInfo(EntityColumnInfo it, string pre)
{
if (it.QuerySql.HasValue())
{
return it.QuerySql+ " AS "+ Builder.GetTranslationColumnName(it.EntityName, it.PropertyName);
}
return pre + Builder.GetTranslationColumnName(it.EntityName, it.PropertyName);
}
public virtual string GetWhereValueString
{
get

View File

@ -47,5 +47,6 @@ namespace SqlSugar
public string UpdateSql { get; set; }
public object ExtendedAttribute { get; set; }
public bool IsDisabledAlterColumn { get; set; }
public string QuerySql { get; set; }
}
}

View File

@ -210,6 +210,7 @@ namespace SqlSugar
public int CreateTableFieldSort { get; set; }
public bool InsertServerTime { get; set; }
public string InsertSql { get; set; }
public string QuerySql { get; set; }
public bool UpdateServerTime { get; set; }
public string UpdateSql { get; set; }
public object ExtendedAttribute{ get; set; }