Navicat for mysql 根据表结构生成C# 实体对象
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='newcxa' AND TABLE_NAME='cf_p_log';
生成结构如下所示:
/// <summary> /// /// </summary> public string Id {get;set;} /// <summary> /// /// </summary> public string UserId {get;set;} /// <summary> /// /// </summary> public string OrgCode {get;set;} /// <summary> /// /// </summary> public string OrgName {get;set;} /// <summary> /// /// </summary> public string OpMAC {get;set;} /// <summary> /// /// </summary> public string OpIp {get;set;} /// <summary> /// /// </summary> public string OpContent {get;set;} /// <summary> /// /// </summary> public DateTime OpTime {get;set;}
删除注释如下所示:
USE INFORMATION_SCHEMA; SELECT CONCAT('',COLUMN_COMMENT,'public ', 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='newcxa' AND TABLE_NAME='cf_p_log';
public string Id {get;set;} public string UserId {get;set;} public string OrgCode {get;set;} public string OrgName {get;set;} public string OpMAC {get;set;} public string OpIp {get;set;} public string OpContent {get;set;} public DateTime OpTime {get;set;}
博客内容主要用于日常学习记录,内容比较随意,如有问题,还需谅解!!!