优化代码生成功能

This commit is contained in:
izory
2021-09-21 20:31:35 +08:00
parent 06ec7b0ddc
commit 37174398c3
19 changed files with 350 additions and 218 deletions

View File

@@ -54,6 +54,18 @@ namespace ZR.Service
return Db.Insertable(parm).RemoveDataCache().ExecuteCommand();
}
/// <summary>
/// 添加
/// </summary>
/// <param name="parm"></param>
/// <param name="iClumns">插入列</param>
/// <param name="ignoreNull">忽略null列</param>
/// <returns></returns>
public int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true)
{
return Db.Insertable(parm).InsertColumns(iClumns).IgnoreColumns(ignoreNullColumn: ignoreNull).ExecuteCommand();
}
/// <summary>
/// 批量添加数据
/// </summary>
@@ -166,7 +178,7 @@ namespace ZR.Service
/// 查询所有数据(无分页,请慎用)
/// </summary>
/// <returns></returns>
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
public List<T> GetAll(bool useCache = false, int cacheSecond = 3600)
{
return Db.Queryable<T>().WithCacheIF(useCache, cacheSecond).ToList();
}

View File

@@ -42,6 +42,8 @@ namespace ZR.Service
/// <returns></returns>
int Add(T parm);
int Add(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = false);
/// <summary>
/// 批量添加数据
/// </summary>

View File

@@ -153,7 +153,7 @@ namespace ZR.Service.System
/// <returns></returns>
public int InsertGenTableColumn(List<GenTableColumn> tableColumn)
{
return Db.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark}).ExecuteCommand();
return Db.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
}
/// <summary>
@@ -163,7 +163,31 @@ namespace ZR.Service.System
/// <returns></returns>
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
{
return Db.Updateable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
foreach (var item in tableColumn)
{
Db.Updateable<GenTableColumn>()
.Where(f => f.TableId == item.TableId)
.SetColumns(it => new GenTableColumn()
{
ColumnComment = item.ColumnComment,
CsharpField = item.CsharpField,
CsharpType = item.CsharpType,
IsQuery = item.IsQuery,
IsEdit = item.IsEdit,
IsInsert = item.IsInsert,
IsList = item.IsList,
QueryType = item.QueryType,
HtmlType = item.HtmlType,
IsRequired = item.IsRequired,
Sort = item.Sort,
Update_time = DateTime.Now,
DictType = item.DictType
})
.Where(f => f.ColumnId == item.ColumnId)
.ExecuteCommand();
}
return 1;
}
}
}