Mysql生成C#实体类

select CONCAT('[Display(Name = "',COLUMN_COMMENT,'")]\r\n',case when CHARACTER_MAXIMUM_LENGTH !=''then concat( '[StringLength(',CHARACTER_MAXIMUM_LENGTH,', ErrorMessage = "{0}长度不能超过{1}")]\r\n') else '' end,'public ', case DATA_TYPE when 'varchar' then 'string' when 'text' then 'string' when 'int' then 'int?' when 'date' then 'DateTime?' when 'decimal' then 'Decimal?' else '' end,' ',COLUMN_NAME,' { get; set; }\r\n' ) field
from information_schema.columns where table_schema='SewerageUser' and TABLE_NAME='SewerageUser'

生成如下实体

 

posted @ 2022-04-02 16:36  忧虑的心  阅读(285)  评论(0)    收藏  举报