自定义列头显示

parent 43b2f77e
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.EntityModels.Other
{
public class ColumnEntity
{
public string Name { get; set; }
public string Comment { get; set; }
}
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.EntityModels.Other;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
...@@ -499,12 +500,12 @@ public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead) ...@@ -499,12 +500,12 @@ public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
return result; return result;
} }
public bool QueryIsAllotId(string tableName) public bool QueryIsAllotId(string tableName, params string[] columns)
{ {
var database = context.Database.GetDbConnection().Database; var database = context.Database.GetDbConnection().Database;
var sql = $@"SELECT column_name FROM information_schema.COLUMNS s var sql = $@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND (column_name='allotId' or column_name='AccountingUnit' or column_name='UnitType');"; WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND column_name in @columns;";
var result = DapperQuery<string>(sql, new { database = database, table_name = tableName }); var result = DapperQuery<string>(sql, new { database = database, table_name = tableName, columns });
var isExist = result?.Count() == 3; var isExist = result?.Count() == 3;
...@@ -512,11 +513,11 @@ public bool QueryIsAllotId(string tableName) ...@@ -512,11 +513,11 @@ public bool QueryIsAllotId(string tableName)
} }
public List<dynamic> QueryCustomColumn(string tableName) public List<ColumnEntity> QueryCustomColumn(string tableName)
{ {
var database = context.Database.GetDbConnection().Database; var database = context.Database.GetDbConnection().Database;
var sql = $@"SELECT column_name,column_comment FROM information_schema.`COLUMNS` WHERE table_schema = @table_schema AND table_name = @table_name AND COLUMN_KEY <> 'PRI' "; var sql = $@"SELECT column_name as Name,ifnull(column_comment,column_name) as comment FROM information_schema.`COLUMNS` WHERE table_schema = @table_schema AND table_name = @table_name AND COLUMN_KEY <> 'PRI' ";
var result = DapperQuery<dynamic>(sql, new { table_schema = database, table_name = tableName })?.ToList(); var result = DapperQuery<ColumnEntity>(sql, new { table_schema = database, table_name = tableName })?.ToList();
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment