Closed hmy4677 closed 1 year ago
public async Task<dynamic> GetGroupDataAsync<T>(Expression<Func<Order, T>> prop)
{
var name=ExpressionTool.GetMemberName(prop);
name = _db.EntityMaintenance.GetDbColumnName<T>(name);
return await _db.Queryable<Order>()
.Select(p => new
{
p.Id,
GroupId = SqlFunc.MappingColumn<T>(name) //动态的属性
}).MergeTable()
.GroupBy(p => p.GroupId)
.Select(p => new
{
p.GroupId,
Count = SqlFunc.AggregateCount(p)
}).ToListAsync();
}
用这个就行了
感谢