public AllDesColumnEntity GetAllColumnList()
{
AllDesColumnEntity list = new AllDesColumnEntity();
string sql = @"SELECT function_id, property_valuename '字段编码', property_displayname '字段名称',* FROM BT_AllColumn WHERE status=0;";
var dt = SqlHelper.ExecuteDataset(dsDB_Read_ConnectionString, CommandType.Text, sql, null).Tables[0].AsEnumerable();
var query = (from t in dt.AsEnumerable()
group t by new { t1 = t.Field<Int32>("function_id") } into m
select new DataItem
{
functionId = m.Key.t1,
}).ToList();
foreach (var item in query)
{
var listChilds = dt.Where(x => x.Field<Int32>("function_id").Equals(item.functionId)).Select(x => new ChildItem() { Id = x.Field<Int32>("function_id"), 字段名称 = x.Field<string>("字段名称"), 字段编码 = x.Field<string>("字段编码") }).ToList();
if (listChilds.Count > 0)
{
item.Child = listChilds;
}
}
list.data = query;
list.total = query.Count;
return list;
}
public class ChildItem
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
/// <summary>
/// 企业ID
/// </summary>
public string 字段名称 { get; set; }
/// <summary>
///
/// </summary>
public string 字段编码 { get; set; }
/// <summary>
///
/// </summary>
public string 是否选中 { get; set; }
}
public class DataItem
{
/// <summary>
///
/// </summary>
public int functionId { get; set; }
/// <summary>
/// 企业查询
/// </summary>
public string 指标名称 { get; set; }
/// <summary>
///
/// </summary>
public string 指标编码 { get; set; }
/// <summary>
///
/// </summary>
public string 是否选中 { get; set; }
/// <summary>
///
/// </summary>
public string url { get; set; }
/// <summary>
///
/// </summary>
public List<ChildItem> Child { get; set; }
}
public class AllDesColumnEntity
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public int total { get; set; }
/// <summary>
///
/// </summary>
public List<DataItem> data { get; set; }
/// <summary>
/// 查询成功
/// </summary>
public string result { get; set; }
/// <summary>
///
/// </summary>
public string msg { get; set; }
}