MySql 表 转为C#实体类 ,sql语句

SELECT
CONCAT(
'/// <summary>\r\n/// ',
COLUMN_COMMENT,
'\r\n/// </summary>\r\npublic ',
CASE
DATA_TYPE
WHEN 'bigint' THEN
'int'
WHEN 'tinyint' THEN
'int'
WHEN 'varchar' THEN
'string'
WHEN 'varbinary' THEN
'string'
WHEN 'text' THEN
'string'
WHEN 'char' THEN
'string'
WHEN 'datetime' THEN
'DateTime'
WHEN 'bit' THEN
'bool'
WHEN 'decimal' THEN
'decimal' ELSE DATA_TYPE
END,
' ',
COLUMN_NAME,
' {get;set;}'
) AS Remarkss
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = 'feixmanagedb'
AND TABLE_NAME = 'systemversioninfo';

 

==============================================================================================================================================

SELECT
CONCAT(
'[Column("',
COLUMN_NAME,
'")]\r\n[DisplayName("',
COLUMN_COMMENT,
'")]\r\npublic ',
CASE
DATA_TYPE
WHEN 'bigint' THEN
'int'
WHEN 'tinyint' THEN
'int'
WHEN 'varchar' THEN
'string'
WHEN 'varbinary' THEN
'string'
WHEN 'text' THEN
'string'
WHEN 'char' THEN
'string'
WHEN 'datetime' THEN
'DateTime'
WHEN 'bit' THEN
'bool'
WHEN 'decimal' THEN
'decimal' ELSE DATA_TYPE
END,
' ',
COLUMN_NAME,
' {get;set;}'
) AS Remarkss
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = 'fxmaintaindb'
AND TABLE_NAME = 'relation_urchase_sales';

 

posted @ 2023-09-12 10:27  剑存古风  阅读(108)  评论(0编辑  收藏  举报