public async Task <IActionResult> Detail(UrlParameter param) { var model = new ViewListModel(); model.Table = (await _tableListService.GetByIdAsync(param.extraValue.Ext_ToInt32())).data; var result = await _tableColumnService.GetListAsync(item => item.TableId == model.Table.Id && item.ViewVisible == 1); model.TableColumn = result.data.OrderBy(c => c.ViewOrder).ToList(); string sql = "select {0} from {1} where {2}"; ViewBag.OutColumn = new Dictionary <string, object>(); var tbName = model.Table.Name; var columnValueResult = await SqlService.Query( string.Format(sql, "*", tbName, "Id=" + param.id)); var columnValue = columnValueResult.First(); ViewBag.ColumnValue = columnValue; foreach (var column in model.TableColumn) { if (column.DataType == ColumnType.Out) { var outSqlModel = new OutSqlModel(column.OutSql); var outColValue = await SysService.GetOutValue(outSqlModel, columnValue[column.Name].ToString()); ViewBag.OutColumn[column.Name] = outColValue.data; } else if (column.DataType == ColumnType.MultiSelect_Out) { var outSqlModel = new OutSqlModel(column.OutSql); var queryResult = await SysService.GetOutData(outSqlModel); //如果保存到外表 查询的是外表值 if (outSqlModel.IsSave) { var selectValues = (await SysService.GetMultiSelectOutValue(outSqlModel, param.id.ToString())).data; var outColValues = queryResult.Where(item => selectValues.Contains(item[outSqlModel.PrimaryKey].ToString())) .Select(item => item[outSqlModel.TextKey]).ToList(); ViewBag.OutColumn[column.Name] = string.Join(",", outColValues); } //否则查询本表此列值 else { ViewBag.OutColumn[column.Name] = columnValue[column.Name]; } } else if (column.DataType == ColumnType.MultiSelect) { var selectValues = columnValueResult.First()[column.Name].ToString().Split(','); var checkStr = column.SelectRange.Split('|'); //1,选项1|2,选项2 var items = new List <SelectListItem>(); var selectText = string.Empty; foreach (var item in checkStr) { if (selectValues.Contains(item.Split(',')[0])) { selectText += item.Split(',')[1] + ","; } } ViewBag.ColumnValue[column.Name] = selectText.Trim(','); } } return(View(model)); }