Navicat for mysql 根據表結構生成C# 實體物件
阿新 • • 發佈:2022-05-17
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;}