MySQL根据表生成实体类

SELECT CONCAT('/// <summary>\n',
'///',column_comment,'\n'
,'/// </summary>','
public ',
(
case LOWER(Data_type)
when 'varchar' then 'string'
when 'text' then 'string'
when 'tinyint' then 'bool'
when 'bit' then 'bool'
when 'bigint' then 'long'
when 'datetime' then 'DateTime'
ELSE Data_type END
),
IF(IS_NULLABLE='YES','?','')
,' ', COLUMN_NAME,' {get;set;}\n') property FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='YourDataBaseName' AND TABLE_NAME='YourTableName' ORDER BY ORDINAL_POSITION ASC;

 

posted on 2025-10-11 17:11  DreamerSix  阅读(0)  评论(0)    收藏  举报