1
This commit is contained in:
@@ -46,9 +46,8 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
var pk = id;
|
||||
TDest entity = new();
|
||||
entity.id = SnowflakeIdHelper.NextId();
|
||||
entity.PropertySetValue(mColumnName, input.item_group_id);
|
||||
entity.PropertySetValue(name,pk);
|
||||
entity.PropertySetValue(name, pk);
|
||||
entities.Add(entity);
|
||||
}
|
||||
}
|
||||
@@ -56,19 +55,27 @@ namespace Tnb.EquipMgr
|
||||
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);
|
||||
}
|
||||
|
||||
protected async Task<dynamic> GetListByMasterId<TRelaction, TDest, TOutput>(string masterId,
|
||||
|
||||
protected async Task<dynamic> GetListById<TRelaction, TDest, TOutput>(string masterId,
|
||||
Expression<Func<TRelaction, bool>> masterFilterExp,
|
||||
Expression<Func<TRelaction, string>> masterSelector,
|
||||
Expression<Func<TDest, bool>> relactionFilterExp)
|
||||
Expression<Func<TDest, object>> srcMap,
|
||||
Expression<Func<TOutput, object>> destMap
|
||||
) where TDest : BaseEntity<string>, new()
|
||||
{
|
||||
var config = new TypeAdapterConfig();
|
||||
config.ForType<TDest, TOutput>();
|
||||
config.ForType<TDest, TOutput>().Map(destMap, srcMap);
|
||||
var list = new List<TOutput>();
|
||||
var itemIds = await _db.Queryable<TRelaction>().Where(masterFilterExp).Select(masterSelector).ToListAsync();
|
||||
if (itemIds?.Count > 0)
|
||||
{
|
||||
var items = await _db.Queryable<TDest>().Where(relactionFilterExp).ToListAsync();
|
||||
var items = await _db.Queryable<TDest>().Where(it=>itemIds.Contains(it.id)).ToListAsync();
|
||||
list = items.Adapt<List<TOutput>>();
|
||||
}
|
||||
return list;
|
||||
|
||||
Reference in New Issue
Block a user