执行代码清理,修复warning

This commit is contained in:
2023-11-06 19:59:12 +08:00
parent c6b8dfc861
commit 1dbb17f103
118 changed files with 5046 additions and 4111 deletions

View File

@@ -30,28 +30,38 @@ namespace Tnb.EquipMgr
protected async Task Relevance<TSrc, TDest>(TSrc input, string mColumnName, string name, Expression<Func<TDest, bool>> deleleExp) where TDest : BaseEntity<string>, new()
where TSrc : BaseMoldMaintainInput
{
if (input == null) throw new ArgumentNullException(nameof(input));
await _db.Deleteable<TDest>().Where(deleleExp).ExecuteCommandAsync();
var entities = new List<TDest>();
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
_ = await _db.Deleteable<TDest>().Where(deleleExp).ExecuteCommandAsync();
List<TDest> entities = new();
if (input.ids?.Count > 0)
{
foreach (var id in input.ids)
foreach (string id in input.ids)
{
var pk = id;
string pk = id;
TDest entity = new();
entity.PropertySetValue(mColumnName, input.id);
entity.PropertySetValue(name, pk);
entities.Add(entity);
}
}
var row = await _db.Insertable(entities).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
int row = await _db.Insertable(entities).ExecuteCommandAsync();
if (row < 1)
{
throw Oops.Oh(ErrorCode.COM1000);
}
}
protected async Task Delete<T>(Expression<Func<T, bool>> delFilter) where T : BaseEntity<string>, new()
{
var row = await _db.Deleteable<T>().Where(delFilter).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1002);
int row = await _db.Deleteable<T>().Where(delFilter).ExecuteCommandAsync();
if (row < 1)
{
throw Oops.Oh(ErrorCode.COM1002);
}
}
@@ -62,13 +72,13 @@ namespace Tnb.EquipMgr
Expression<Func<TOutput, object>> destMap
) where TDest : BaseEntity<string>, new()
{
var config = new TypeAdapterConfig();
config.ForType<TDest, TOutput>().Map(destMap, srcMap);
var list = new List<TOutput>();
var itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
TypeAdapterConfig config = new();
_ = config.ForType<TDest, TOutput>().Map(destMap, srcMap);
List<TOutput> list = new();
List<string> itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
if (itemIds?.Count > 0)
{
var items = await _db.Queryable<TDest>().Where(it => itemIds.Contains(it.id)).ToListAsync();
List<TDest> items = await _db.Queryable<TDest>().Where(it => itemIds.Contains(it.id)).ToListAsync();
list = items.Adapt<List<TOutput>>();
}
return list;