namespace CloudGaming.Shared.Admin.Extensions.Dict; /// /// 字典信息 /// public class DictInfo { public DictInfo(DictAttribute dict, List data, PropertyInfo propertyInfo) { Dict = dict; Data = data; PropertyInfo = propertyInfo; } public DictAttribute Dict { get; set; } public List Data { get; set; } public PropertyInfo PropertyInfo { get; set; } public string Name => PropertyInfo.Name; public void SetData(object? value) { Data.Add(value); } private List DataSource { get; set; } = []; public List BuildDataSource(IFreeSql freeSql) { if (DataSource.Count > 0) { return DataSource; } var dictTableName = Dict.DictTableName; var dictCode = Dict.DictCode; var dictName = Dict.DictName; // 生成 sql 查询数据 var sql = $"SELECT {dictCode} as Code,{dictName} as Name FROM {dictTableName} WHERE {dictCode} IN ({string.Join(",", Data)})"; // 查询数据 DataSource = freeSql.Ado.Query(sql); return DataSource; } }