MySQL根据表字段生成C#Model语句
可以直接通过MYSQL元数据库信息,根据表字段信息生成C#类属性,使用时替换{DBName}和{TableName}(花括号也要去掉)
USE INFORMATION_SCHEMA; 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;}') FROM COLUMNS WHERE TABLE_SCHEMA='{DBName}' AND TABLE_NAME='{TableName}';