新增生成器选项BuilderOption,便于批量设置生成参数
This commit is contained in:
parent
b7d76f9688
commit
f00cbedd6d
|
@ -0,0 +1,61 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace XCode.Code
|
||||||
|
{
|
||||||
|
/// <summary>生成器选项</summary>
|
||||||
|
public class BuilderOption
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>命名空间</summary>
|
||||||
|
public String Namespace { get; set; }
|
||||||
|
|
||||||
|
/// <summary>引用命名空间</summary>
|
||||||
|
public HashSet<String> Usings { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
/// <summary>纯净类</summary>
|
||||||
|
public Boolean Pure { get; set; }
|
||||||
|
|
||||||
|
/// <summary>生成接口</summary>
|
||||||
|
public Boolean Interface { get; set; }
|
||||||
|
|
||||||
|
/// <summary>类名后缀。如Model/Dto等</summary>
|
||||||
|
public String ClassPrefix { get; set; }
|
||||||
|
|
||||||
|
/// <summary>基类</summary>
|
||||||
|
public String BaseClass { get; set; }
|
||||||
|
|
||||||
|
/// <summary>是否分部类</summary>
|
||||||
|
public Boolean Partial { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>输出目录</summary>
|
||||||
|
public String Output { get; set; }
|
||||||
|
|
||||||
|
/// <summary>连接名</summary>
|
||||||
|
public String ConnName { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 构造
|
||||||
|
/// <summary>实例化</summary>
|
||||||
|
public BuilderOption()
|
||||||
|
{
|
||||||
|
Namespace = GetType().Namespace;
|
||||||
|
|
||||||
|
Usings.Add("System");
|
||||||
|
Usings.Add("System.Collections.Generic");
|
||||||
|
Usings.Add("System.ComponentModel");
|
||||||
|
Usings.Add("System.Runtime.Serialization");
|
||||||
|
Usings.Add("System.Web.Script.Serialization");
|
||||||
|
Usings.Add("System.Xml.Serialization");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 方法
|
||||||
|
/// <summary>克隆</summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public BuilderOption Clone() => MemberwiseClone() as BuilderOption;
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,46 +22,17 @@ namespace XCode.Code
|
||||||
/// <summary>类名。默认Table.Name</summary>
|
/// <summary>类名。默认Table.Name</summary>
|
||||||
public String ClassName { get; set; }
|
public String ClassName { get; set; }
|
||||||
|
|
||||||
/// <summary>命名空间</summary>
|
/// <summary>生成器选项</summary>
|
||||||
public String Namespace { get; set; }
|
public BuilderOption Option { get; set; } = new BuilderOption();
|
||||||
|
|
||||||
/// <summary>引用命名空间</summary>
|
|
||||||
public HashSet<String> Usings { get; } = new HashSet<String>(StringComparer.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
/// <summary>纯净类</summary>
|
|
||||||
public Boolean Pure { get; set; }
|
|
||||||
|
|
||||||
/// <summary>生成接口</summary>
|
|
||||||
public Boolean Interface { get; set; }
|
|
||||||
|
|
||||||
/// <summary>基类</summary>
|
|
||||||
public String BaseClass { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否分部类</summary>
|
|
||||||
public Boolean Partial { get; set; } = true;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 构造
|
|
||||||
/// <summary>实例化</summary>
|
|
||||||
public ClassBuilder()
|
|
||||||
{
|
|
||||||
Namespace = GetType().Namespace;
|
|
||||||
|
|
||||||
Usings.Add("System");
|
|
||||||
Usings.Add("System.Collections.Generic");
|
|
||||||
Usings.Add("System.ComponentModel");
|
|
||||||
Usings.Add("System.Runtime.Serialization");
|
|
||||||
Usings.Add("System.Web.Script.Serialization");
|
|
||||||
Usings.Add("System.Xml.Serialization");
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 静态快速
|
#region 静态快速
|
||||||
/// <summary>加载模型文件</summary>
|
/// <summary>加载模型文件</summary>
|
||||||
/// <param name="xmlFile"></param>
|
/// <param name="xmlFile">Xml模型文件</param>
|
||||||
/// <param name="atts"></param>
|
/// <param name="option">生成可选项</param>
|
||||||
|
/// <param name="atts">扩展属性字典</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IList<IDataTable> LoadModels(String xmlFile, out IDictionary<String, String> atts)
|
public static IList<IDataTable> LoadModels(String xmlFile, BuilderOption option, out IDictionary<String, String> atts)
|
||||||
{
|
{
|
||||||
if (xmlFile.IsNullOrEmpty())
|
if (xmlFile.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
@ -85,27 +56,36 @@ namespace XCode.Code
|
||||||
["xs:schemaLocation"] = "http://www.newlifex.com http://www.newlifex.com/Model2020.xsd"
|
["xs:schemaLocation"] = "http://www.newlifex.com http://www.newlifex.com/Model2020.xsd"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (option != null)
|
||||||
|
{
|
||||||
|
option.Output = atts["Output"] ?? Path.GetDirectoryName(xmlFile);
|
||||||
|
option.Namespace = atts["NameSpace"] ?? Path.GetFileNameWithoutExtension(xmlFile);
|
||||||
|
option.ConnName = atts["ConnName"];
|
||||||
|
option.BaseClass = atts["BaseClass"];
|
||||||
|
}
|
||||||
|
|
||||||
// 导入模型
|
// 导入模型
|
||||||
return ModelHelper.FromXml(xmlContent, DAL.CreateTable, atts);
|
return ModelHelper.FromXml(xmlContent, DAL.CreateTable, atts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>生成简易版模型</summary>
|
/// <summary>生成简易版模型</summary>
|
||||||
/// <param name="tables">表集合</param>
|
/// <param name="tables">表集合</param>
|
||||||
/// <param name="output">输出目录</param>
|
/// <param name="option">可选项</param>
|
||||||
/// <param name="prefix">后缀。附在实体类名和文件名后面</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Int32 BuildModels(IList<IDataTable> tables, String output, String prefix = null)
|
public static Int32 BuildModels(IList<IDataTable> tables, BuilderOption option = null)
|
||||||
{
|
{
|
||||||
|
if (option == null) option = new BuilderOption();
|
||||||
|
|
||||||
|
option.Pure = true;
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var item in tables)
|
foreach (var item in tables)
|
||||||
{
|
{
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = item,
|
Table = item,
|
||||||
Output = output,
|
Option = option,
|
||||||
Pure = true,
|
|
||||||
};
|
};
|
||||||
if (!prefix.IsNullOrEmpty()) builder.ClassName = item.Name + prefix;
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
builder.Save(null, true, false);
|
builder.Save(null, true, false);
|
||||||
|
|
||||||
|
@ -117,21 +97,22 @@ namespace XCode.Code
|
||||||
|
|
||||||
/// <summary>生成简易版实体接口</summary>
|
/// <summary>生成简易版实体接口</summary>
|
||||||
/// <param name="tables">表集合</param>
|
/// <param name="tables">表集合</param>
|
||||||
/// <param name="output">输出目录</param>
|
/// <param name="option">可选项</param>
|
||||||
/// <param name="prefix">后缀。附在实体类名和文件名后面</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Int32 BuildInterfaces(IList<IDataTable> tables, String output, String prefix = null)
|
public static Int32 BuildInterfaces(IList<IDataTable> tables, BuilderOption option = null)
|
||||||
{
|
{
|
||||||
|
if (option == null) option = new BuilderOption();
|
||||||
|
|
||||||
|
option.Interface = true;
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (var item in tables)
|
foreach (var item in tables)
|
||||||
{
|
{
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = item,
|
Table = item,
|
||||||
Output = output,
|
Option = option,
|
||||||
Interface = true,
|
|
||||||
};
|
};
|
||||||
if (!prefix.IsNullOrEmpty()) builder.ClassName = "I" + item.Name + prefix;
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
builder.Save(null, true, false);
|
builder.Save(null, true, false);
|
||||||
|
|
||||||
|
@ -146,7 +127,7 @@ namespace XCode.Code
|
||||||
/// <summary>执行生成</summary>
|
/// <summary>执行生成</summary>
|
||||||
public virtual void Execute()
|
public virtual void Execute()
|
||||||
{
|
{
|
||||||
if (ClassName.IsNullOrEmpty()) ClassName = Interface ? ("I" + Table.Name) : Table.Name;
|
if (ClassName.IsNullOrEmpty()) ClassName = (Option.Interface ? ("I" + Table.Name) : Table.Name) + Option.ClassPrefix;
|
||||||
//WriteLog("生成 {0} {1}", Table.Name, Table.DisplayName);
|
//WriteLog("生成 {0} {1}", Table.Name, Table.DisplayName);
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -163,14 +144,14 @@ namespace XCode.Code
|
||||||
protected virtual void OnExecuting()
|
protected virtual void OnExecuting()
|
||||||
{
|
{
|
||||||
// 引用命名空间
|
// 引用命名空间
|
||||||
var us = Usings.OrderBy(e => e.StartsWith("System") ? 0 : 1).ThenBy(e => e).ToArray();
|
var us = Option.Usings.OrderBy(e => e.StartsWith("System") ? 0 : 1).ThenBy(e => e).ToArray();
|
||||||
foreach (var item in us)
|
foreach (var item in us)
|
||||||
{
|
{
|
||||||
WriteLine("using {0};", item);
|
WriteLine("using {0};", item);
|
||||||
}
|
}
|
||||||
WriteLine();
|
WriteLine();
|
||||||
|
|
||||||
var ns = Namespace;
|
var ns = Option.Namespace;
|
||||||
if (!ns.IsNullOrEmpty())
|
if (!ns.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
WriteLine("namespace {0}", ns);
|
WriteLine("namespace {0}", ns);
|
||||||
|
@ -192,10 +173,10 @@ namespace XCode.Code
|
||||||
if (!bc.IsNullOrEmpty()) bc = " : " + bc;
|
if (!bc.IsNullOrEmpty()) bc = " : " + bc;
|
||||||
|
|
||||||
// 分部类
|
// 分部类
|
||||||
var pc = Partial ? " partial" : "";
|
var pc = Option.Partial ? " partial" : "";
|
||||||
|
|
||||||
// 类接口
|
// 类接口
|
||||||
if (Interface)
|
if (Option.Interface)
|
||||||
WriteLine("public{2} interface {0}{1}", cn, bc, pc);
|
WriteLine("public{2} interface {0}{1}", cn, bc, pc);
|
||||||
else
|
else
|
||||||
WriteLine("public{2} class {0}{1}", cn, bc, pc);
|
WriteLine("public{2} class {0}{1}", cn, bc, pc);
|
||||||
|
@ -208,7 +189,7 @@ namespace XCode.Code
|
||||||
|
|
||||||
/// <summary>获取基类</summary>
|
/// <summary>获取基类</summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual String GetBaseClass() => BaseClass;
|
protected virtual String GetBaseClass() => Option.BaseClass;
|
||||||
|
|
||||||
/// <summary>实体类头部</summary>
|
/// <summary>实体类头部</summary>
|
||||||
protected virtual void BuildAttribute()
|
protected virtual void BuildAttribute()
|
||||||
|
@ -217,7 +198,7 @@ namespace XCode.Code
|
||||||
var des = Table.Description;
|
var des = Table.Description;
|
||||||
WriteLine("/// <summary>{0}</summary>", des);
|
WriteLine("/// <summary>{0}</summary>", des);
|
||||||
|
|
||||||
if (!Pure && !Interface)
|
if (!Option.Pure && !Option.Interface)
|
||||||
{
|
{
|
||||||
WriteLine("[Serializable]");
|
WriteLine("[Serializable]");
|
||||||
WriteLine("[DataObject]");
|
WriteLine("[DataObject]");
|
||||||
|
@ -232,8 +213,7 @@ namespace XCode.Code
|
||||||
// 类接口
|
// 类接口
|
||||||
WriteLine("}");
|
WriteLine("}");
|
||||||
|
|
||||||
var ns = Namespace;
|
if (!Option.Namespace.IsNullOrEmpty())
|
||||||
if (!ns.IsNullOrEmpty())
|
|
||||||
{
|
{
|
||||||
Writer.Write("}");
|
Writer.Write("}");
|
||||||
}
|
}
|
||||||
|
@ -260,7 +240,7 @@ namespace XCode.Code
|
||||||
var des = dc.Description;
|
var des = dc.Description;
|
||||||
WriteLine("/// <summary>{0}</summary>", des);
|
WriteLine("/// <summary>{0}</summary>", des);
|
||||||
|
|
||||||
if (!Pure && !Interface)
|
if (!Option.Pure && !Option.Interface)
|
||||||
{
|
{
|
||||||
if (!des.IsNullOrEmpty()) WriteLine("[Description(\"{0}\")]", des);
|
if (!des.IsNullOrEmpty()) WriteLine("[Description(\"{0}\")]", des);
|
||||||
|
|
||||||
|
@ -271,7 +251,7 @@ namespace XCode.Code
|
||||||
var type = dc.Properties["Type"];
|
var type = dc.Properties["Type"];
|
||||||
if (type.IsNullOrEmpty()) type = dc.DataType?.Name;
|
if (type.IsNullOrEmpty()) type = dc.DataType?.Name;
|
||||||
|
|
||||||
if (Interface)
|
if (Option.Interface)
|
||||||
WriteLine("{0} {1} {{ get; set; }}", type, dc.Name);
|
WriteLine("{0} {1} {{ get; set; }}", type, dc.Name);
|
||||||
else
|
else
|
||||||
WriteLine("public {0} {1} {{ get; set; }}", type, dc.Name);
|
WriteLine("public {0} {1} {{ get; set; }}", type, dc.Name);
|
||||||
|
@ -338,20 +318,17 @@ namespace XCode.Code
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 保存
|
#region 保存
|
||||||
/// <summary>输出目录</summary>
|
|
||||||
public String Output { get; set; }
|
|
||||||
|
|
||||||
/// <summary>保存文件,返回文件路径</summary>
|
/// <summary>保存文件,返回文件路径</summary>
|
||||||
public virtual String Save(String ext = null, Boolean overwrite = true, Boolean chineseFileName = true)
|
public virtual String Save(String ext = null, Boolean overwrite = true, Boolean chineseFileName = true)
|
||||||
{
|
{
|
||||||
var p = Output;
|
var p = Option.Output;
|
||||||
|
|
||||||
if (ext.IsNullOrEmpty())
|
if (ext.IsNullOrEmpty())
|
||||||
ext = ".cs";
|
ext = ".cs";
|
||||||
else if (!ext.Contains("."))
|
else if (!ext.Contains("."))
|
||||||
ext += ".cs";
|
ext += ".cs";
|
||||||
|
|
||||||
if (Interface)
|
if (Option.Interface)
|
||||||
p = p.CombinePath(ClassName + ext);
|
p = p.CombinePath(ClassName + ext);
|
||||||
else if (chineseFileName && !Table.DisplayName.IsNullOrEmpty())
|
else if (chineseFileName && !Table.DisplayName.IsNullOrEmpty())
|
||||||
p = p.CombinePath(Table.DisplayName + ext);
|
p = p.CombinePath(Table.DisplayName + ext);
|
||||||
|
|
|
@ -15,9 +15,6 @@ namespace XCode.Code
|
||||||
public class EntityBuilder : ClassBuilder
|
public class EntityBuilder : ClassBuilder
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
/// <summary>连接名</summary>
|
|
||||||
public String ConnName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>泛型实体类。泛型参数名TEntity</summary>
|
/// <summary>泛型实体类。泛型参数名TEntity</summary>
|
||||||
public Boolean GenericType { get; set; }
|
public Boolean GenericType { get; set; }
|
||||||
|
|
||||||
|
@ -28,20 +25,6 @@ namespace XCode.Code
|
||||||
public IList<IDataTable> AllTables { get; set; } = new List<IDataTable>();
|
public IList<IDataTable> AllTables { get; set; } = new List<IDataTable>();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 构造
|
|
||||||
/// <summary>实例化</summary>
|
|
||||||
public EntityBuilder()
|
|
||||||
{
|
|
||||||
Usings.Add("XCode");
|
|
||||||
Usings.Add("XCode.Configuration");
|
|
||||||
Usings.Add("XCode.DataAccessLayer");
|
|
||||||
|
|
||||||
Pure = false;
|
|
||||||
|
|
||||||
if (Debug) Log = XTrace.Log;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 静态快速
|
#region 静态快速
|
||||||
/// <summary>为Xml模型文件生成实体类</summary>
|
/// <summary>为Xml模型文件生成实体类</summary>
|
||||||
/// <param name="xmlFile">模型文件</param>
|
/// <param name="xmlFile">模型文件</param>
|
||||||
|
@ -60,72 +43,32 @@ namespace XCode.Code
|
||||||
xmlFile = xmlFile.GetBasePath();
|
xmlFile = xmlFile.GetBasePath();
|
||||||
if (!File.Exists(xmlFile)) throw new FileNotFoundException("指定模型文件不存在!", xmlFile);
|
if (!File.Exists(xmlFile)) throw new FileNotFoundException("指定模型文件不存在!", xmlFile);
|
||||||
|
|
||||||
|
var option = new BuilderOption
|
||||||
|
{
|
||||||
|
Output = output,
|
||||||
|
Namespace = nameSpace,
|
||||||
|
ConnName = connName,
|
||||||
|
};
|
||||||
|
|
||||||
// 导入模型
|
// 导入模型
|
||||||
var tables = LoadModels(xmlFile, out var atts);
|
var tables = LoadModels(xmlFile, option, out var atts);
|
||||||
if (tables.Count == 0) return 0;
|
if (tables.Count == 0) return 0;
|
||||||
|
|
||||||
// 输出
|
// 反哺。确保输出空特性
|
||||||
if (!output.IsNullOrEmpty())
|
atts["Output"] = option.Output + "";
|
||||||
atts["Output"] = output;
|
atts["NameSpace"] = option.Namespace + "";
|
||||||
else
|
atts["ConnName"] = option.ConnName + "";
|
||||||
output = atts["Output"];
|
atts["BaseClass"] = option.BaseClass + "";
|
||||||
if (output.IsNullOrEmpty()) output = Path.GetDirectoryName(xmlFile);
|
atts.Remove("NameIgnoreCase");
|
||||||
|
atts.Remove("IgnoreNameCase");
|
||||||
// 命名空间
|
|
||||||
if (!nameSpace.IsNullOrEmpty())
|
|
||||||
atts["NameSpace"] = nameSpace;
|
|
||||||
else
|
|
||||||
nameSpace = atts["NameSpace"];
|
|
||||||
if (nameSpace.IsNullOrEmpty()) nameSpace = Path.GetFileNameWithoutExtension(xmlFile);
|
|
||||||
|
|
||||||
// 连接名
|
|
||||||
if (!connName.IsNullOrEmpty())
|
|
||||||
atts["ConnName"] = connName;
|
|
||||||
else
|
|
||||||
connName = atts["ConnName"];
|
|
||||||
if (connName.IsNullOrEmpty() && !nameSpace.IsNullOrEmpty()) connName = nameSpace.Split(".").LastOrDefault(e => !e.EqualIgnoreCase("Entity"));
|
|
||||||
|
|
||||||
// 基类
|
|
||||||
var baseClass = "";
|
|
||||||
if (!baseClass.IsNullOrEmpty())
|
|
||||||
atts["BaseClass"] = baseClass;
|
|
||||||
else
|
|
||||||
baseClass = atts["BaseClass"];
|
|
||||||
|
|
||||||
// 中文文件名
|
// 中文文件名
|
||||||
if (chineseFileName != null)
|
if (chineseFileName != null)
|
||||||
{
|
|
||||||
atts["ChineseFileName"] = chineseFileName.Value ? "True" : "False";
|
atts["ChineseFileName"] = chineseFileName.Value ? "True" : "False";
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
chineseFileName = atts["ChineseFileName"].ToBoolean(true);
|
chineseFileName = atts["ChineseFileName"].ToBoolean(true);
|
||||||
}
|
|
||||||
|
|
||||||
//// 忽略表名/字段名称大小写
|
var rs = BuildTables(tables, option, chineseFileName.Value);
|
||||||
//if (ignoreNameCase != null)
|
|
||||||
//{
|
|
||||||
// atts["IgnoreNameCase"] = ignoreNameCase.Value ? "True" : "False";
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// var str = atts["IgnoreNameCase"];
|
|
||||||
// if (str.IsNullOrEmpty()) str = atts["NameIgnoreCase"];
|
|
||||||
// ignoreNameCase = str.ToBoolean();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//XTrace.WriteLine("代码生成源:{0}", xmlFile);
|
|
||||||
|
|
||||||
var rs = BuildTables(tables, output, nameSpace, connName, baseClass, chineseFileName.Value);
|
|
||||||
|
|
||||||
// 确保输出空特性
|
|
||||||
if (atts["Output"].IsNullOrEmpty()) atts["Output"] = "";
|
|
||||||
if (atts["NameSpace"].IsNullOrEmpty()) atts["NameSpace"] = "";
|
|
||||||
if (atts["ConnName"].IsNullOrEmpty()) atts["ConnName"] = "";
|
|
||||||
if (atts["BaseClass"].IsNullOrEmpty()) atts["BaseClass"] = "Entity";
|
|
||||||
//if (atts["IgnoreNameCase"].IsNullOrEmpty()) atts["IgnoreNameCase"] = true + "";
|
|
||||||
atts.Remove("NameIgnoreCase");
|
|
||||||
atts.Remove("IgnoreNameCase");
|
|
||||||
|
|
||||||
// 更新xsd
|
// 更新xsd
|
||||||
atts["xmlns"] = atts["xmlns"].Replace("ModelSchema", "Model2020");
|
atts["xmlns"] = atts["xmlns"].Replace("ModelSchema", "Model2020");
|
||||||
|
@ -141,19 +84,16 @@ namespace XCode.Code
|
||||||
|
|
||||||
/// <summary>为Xml模型文件生成实体类</summary>
|
/// <summary>为Xml模型文件生成实体类</summary>
|
||||||
/// <param name="tables">模型文件</param>
|
/// <param name="tables">模型文件</param>
|
||||||
/// <param name="output">输出目录</param>
|
/// <param name="option">生成可选项</param>
|
||||||
/// <param name="nameSpace">命名空间</param>
|
|
||||||
/// <param name="connName">连接名</param>
|
|
||||||
/// <param name="baseClass">基类</param>
|
|
||||||
/// <param name="chineseFileName">是否中文名称</param>
|
/// <param name="chineseFileName">是否中文名称</param>
|
||||||
public static Int32 BuildTables(IList<IDataTable> tables, String output = null, String nameSpace = null, String connName = null, String baseClass = null, Boolean chineseFileName = true)
|
public static Int32 BuildTables(IList<IDataTable> tables, BuilderOption option, Boolean chineseFileName = true)
|
||||||
{
|
{
|
||||||
if (tables == null || tables.Count == 0) return 0;
|
if (tables == null || tables.Count == 0) return 0;
|
||||||
|
|
||||||
output = output.GetBasePath();
|
//output = output.GetBasePath();
|
||||||
|
|
||||||
// 连接名
|
//// 连接名
|
||||||
if (connName.IsNullOrEmpty() && !nameSpace.IsNullOrEmpty() && nameSpace.Contains(".")) connName = nameSpace.Substring(nameSpace.LastIndexOf(".") + 1);
|
//if (connName.IsNullOrEmpty() && !nameSpace.IsNullOrEmpty() && nameSpace.Contains(".")) connName = nameSpace.Substring(nameSpace.LastIndexOf(".") + 1);
|
||||||
|
|
||||||
//XTrace.WriteLine("代码生成:{0} 输出:{1} 命名空间:{2} 连接名:{3} 基类:{4}", tables.Count, output, nameSpace, connName, baseClass);
|
//XTrace.WriteLine("代码生成:{0} 输出:{1} 命名空间:{2} 连接名:{3} 基类:{4}", tables.Count, output, nameSpace, connName, baseClass);
|
||||||
|
|
||||||
|
@ -161,13 +101,15 @@ namespace XCode.Code
|
||||||
foreach (var item in tables)
|
foreach (var item in tables)
|
||||||
{
|
{
|
||||||
var builder = new EntityBuilder { AllTables = tables, };
|
var builder = new EntityBuilder { AllTables = tables, };
|
||||||
|
if (option != null) builder.Option = option;
|
||||||
|
|
||||||
builder.Load(item);
|
builder.Load(item);
|
||||||
|
|
||||||
if (!output.IsNullOrEmpty()) builder.Output = output;
|
//var option = builder.Option;
|
||||||
if (!nameSpace.IsNullOrEmpty()) builder.Namespace = nameSpace;
|
//if (!output.IsNullOrEmpty()) option.Output = output;
|
||||||
if (!connName.IsNullOrEmpty()) builder.ConnName = connName;
|
//if (!nameSpace.IsNullOrEmpty()) option.Namespace = nameSpace;
|
||||||
if (!baseClass.IsNullOrEmpty()) builder.BaseClass = baseClass;
|
//if (!connName.IsNullOrEmpty()) builder.ConnName = connName;
|
||||||
|
//if (!baseClass.IsNullOrEmpty()) option.BaseClass = baseClass;
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
builder.Save(null, true, chineseFileName);
|
builder.Save(null, true, chineseFileName);
|
||||||
|
@ -181,31 +123,6 @@ namespace XCode.Code
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>为Xml模型文件生成实体类</summary>
|
|
||||||
/// <param name="tables">模型文件</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Int32 BuildTables(IList<IDataTable> tables)
|
|
||||||
{
|
|
||||||
var count = 0;
|
|
||||||
foreach (var item in tables)
|
|
||||||
{
|
|
||||||
var builder = new EntityBuilder { AllTables = tables, };
|
|
||||||
|
|
||||||
builder.Load(item);
|
|
||||||
|
|
||||||
builder.Execute();
|
|
||||||
builder.Save(null, true, true);
|
|
||||||
|
|
||||||
builder.Business = true;
|
|
||||||
builder.Execute();
|
|
||||||
builder.Save(null, false, true);
|
|
||||||
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 方法
|
#region 方法
|
||||||
|
@ -215,22 +132,24 @@ namespace XCode.Code
|
||||||
{
|
{
|
||||||
Table = table;
|
Table = table;
|
||||||
|
|
||||||
|
var option = Option;
|
||||||
|
|
||||||
// 命名空间
|
// 命名空间
|
||||||
var str = table.Properties["Namespace"];
|
var str = table.Properties["Namespace"];
|
||||||
if (!str.IsNullOrEmpty()) Namespace = str;
|
if (!str.IsNullOrEmpty()) option.Namespace = str;
|
||||||
|
|
||||||
// 连接名
|
// 连接名
|
||||||
var connName = table.ConnName;
|
var connName = table.ConnName;
|
||||||
if (connName.IsNullOrEmpty() && !Namespace.IsNullOrEmpty())
|
if (connName.IsNullOrEmpty() && !option.Namespace.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var p = Namespace.LastIndexOf('.');
|
var p = option.Namespace.LastIndexOf('.');
|
||||||
if (p > 0) connName = Namespace.Substring(p + 1);
|
if (p > 0) connName = option.Namespace.Substring(p + 1);
|
||||||
}
|
}
|
||||||
if (!connName.IsNullOrEmpty()) ConnName = connName;
|
if (!connName.IsNullOrEmpty()) option.ConnName = connName;
|
||||||
|
|
||||||
// 基类
|
// 基类
|
||||||
str = table.Properties["BaseClass"];
|
str = table.Properties["BaseClass"];
|
||||||
if (!str.IsNullOrEmpty()) BaseClass = str;
|
if (!str.IsNullOrEmpty()) option.BaseClass = str;
|
||||||
|
|
||||||
// 泛型实体类
|
// 泛型实体类
|
||||||
str = table.Properties["RenderGenEntity"];
|
str = table.Properties["RenderGenEntity"];
|
||||||
|
@ -242,7 +161,7 @@ namespace XCode.Code
|
||||||
|
|
||||||
// 输出目录
|
// 输出目录
|
||||||
str = table.Properties["Output"];
|
str = table.Properties["Output"];
|
||||||
if (!str.IsNullOrEmpty()) Output = str.GetBasePath();
|
if (!str.IsNullOrEmpty()) option.Output = str.GetBasePath();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -251,9 +170,9 @@ namespace XCode.Code
|
||||||
public override void Execute()
|
public override void Execute()
|
||||||
{
|
{
|
||||||
// 增加常用命名空间
|
// 增加常用命名空间
|
||||||
if (Business) AddNameSpace();
|
AddNameSpace();
|
||||||
|
|
||||||
if (ClassName.IsNullOrEmpty()) ClassName = Interface ? ("I" + Table.Name) : Table.Name;
|
if (ClassName.IsNullOrEmpty()) ClassName = (Option.Interface ? ("I" + Table.Name) : Table.Name) + Option.ClassPrefix;
|
||||||
if (GenericType) ClassName += "<TEntity>";
|
if (GenericType) ClassName += "<TEntity>";
|
||||||
|
|
||||||
base.Execute();
|
base.Execute();
|
||||||
|
@ -293,7 +212,7 @@ namespace XCode.Code
|
||||||
// 数据类的基类只有接口,业务类基类则比较复杂
|
// 数据类的基类只有接口,业务类基类则比较复杂
|
||||||
if (!Business) return "I" + Table.Name;
|
if (!Business) return "I" + Table.Name;
|
||||||
|
|
||||||
var name = BaseClass;
|
var name = Option.BaseClass;
|
||||||
if (name.IsNullOrEmpty()) name = "Entity";
|
if (name.IsNullOrEmpty()) name = "Entity";
|
||||||
|
|
||||||
if (GenericType)
|
if (GenericType)
|
||||||
|
@ -333,8 +252,7 @@ namespace XCode.Code
|
||||||
BuildInterface();
|
BuildInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
var ns = Namespace;
|
if (!Option.Namespace.IsNullOrEmpty())
|
||||||
if (!ns.IsNullOrEmpty())
|
|
||||||
{
|
{
|
||||||
Writer.Write("}");
|
Writer.Write("}");
|
||||||
}
|
}
|
||||||
|
@ -343,8 +261,13 @@ namespace XCode.Code
|
||||||
/// <summary>增加常用命名空间</summary>
|
/// <summary>增加常用命名空间</summary>
|
||||||
protected virtual void AddNameSpace()
|
protected virtual void AddNameSpace()
|
||||||
{
|
{
|
||||||
var us = Usings;
|
var us = Option.Usings;
|
||||||
if (!Pure && !us.Contains("System.Web"))
|
|
||||||
|
us.Add("XCode");
|
||||||
|
us.Add("XCode.Configuration");
|
||||||
|
us.Add("XCode.DataAccessLayer");
|
||||||
|
|
||||||
|
if (Business && !Option.Pure && !us.Contains("System.Web"))
|
||||||
{
|
{
|
||||||
us.Add("System.IO");
|
us.Add("System.IO");
|
||||||
us.Add("System.Linq");
|
us.Add("System.Linq");
|
||||||
|
@ -388,7 +311,7 @@ namespace XCode.Code
|
||||||
}
|
}
|
||||||
|
|
||||||
var cn = dt.Properties["ConnName"];
|
var cn = dt.Properties["ConnName"];
|
||||||
if (cn.IsNullOrEmpty()) cn = ConnName;
|
if (cn.IsNullOrEmpty()) cn = Option.ConnName;
|
||||||
WriteLine("[BindTable(\"{0}\", Description = \"{1}\", ConnName = \"{2}\", DbType = DatabaseType.{3})]", dt.TableName, dt.Description, cn, dt.DbType);
|
WriteLine("[BindTable(\"{0}\", Description = \"{1}\", ConnName = \"{2}\", DbType = DatabaseType.{3})]", dt.TableName, dt.Description, cn, dt.DbType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +334,7 @@ namespace XCode.Code
|
||||||
if (dc.Properties.TryGetValue("Attribute", out var att))
|
if (dc.Properties.TryGetValue("Attribute", out var att))
|
||||||
WriteLine("[{0}]", att.Replace("{name}", dc.Name));
|
WriteLine("[{0}]", att.Replace("{name}", dc.Name));
|
||||||
|
|
||||||
if (!Pure)
|
if (!Option.Pure)
|
||||||
{
|
{
|
||||||
var dis = dc.DisplayName;
|
var dis = dc.DisplayName;
|
||||||
if (!dis.IsNullOrEmpty()) WriteLine("[DisplayName(\"{0}\")]", dis);
|
if (!dis.IsNullOrEmpty()) WriteLine("[DisplayName(\"{0}\")]", dis);
|
||||||
|
@ -429,7 +352,7 @@ namespace XCode.Code
|
||||||
else
|
else
|
||||||
WriteLine("[BindColumn(\"{0}\", \"{1}\", \"{2}\"{3})]", dc.ColumnName, dc.Description, dc.RawType, dc.Master ? ", Master = true" : "");
|
WriteLine("[BindColumn(\"{0}\", \"{1}\", \"{2}\"{3})]", dc.ColumnName, dc.Description, dc.RawType, dc.Master ? ", Master = true" : "");
|
||||||
|
|
||||||
if (Interface)
|
if (Option.Interface)
|
||||||
WriteLine("{0} {1} {{ get; set; }}", type, dc.Name);
|
WriteLine("{0} {1} {{ get; set; }}", type, dc.Name);
|
||||||
else
|
else
|
||||||
WriteLine("public {0} {1} {{ get => _{1}; set {{ if (OnPropertyChanging(\"{1}\", value)) {{ _{1} = value; OnPropertyChanged(\"{1}\"); }} }} }}", type, dc.Name);
|
WriteLine("public {0} {1} {{ get => _{1}; set {{ if (OnPropertyChanging(\"{1}\", value)) {{ _{1} = value; OnPropertyChanged(\"{1}\"); }} }} }}", type, dc.Name);
|
||||||
|
|
|
@ -15,9 +15,12 @@ namespace XUnitTest.XCode.Code
|
||||||
{
|
{
|
||||||
private IList<IDataTable> _tables;
|
private IList<IDataTable> _tables;
|
||||||
private IDataTable _table;
|
private IDataTable _table;
|
||||||
|
private BuilderOption _option;
|
||||||
|
|
||||||
public ClassBuilderTests()
|
public ClassBuilderTests()
|
||||||
{
|
{
|
||||||
_tables = ClassBuilder.LoadModels(@"..\..\XCode\Membership\Member.xml", out _);
|
_option = new BuilderOption();
|
||||||
|
_tables = ClassBuilder.LoadModels(@"..\..\XCode\Membership\Member.xml", _option, out _);
|
||||||
_table = _tables.FirstOrDefault(e => e.Name == "User");
|
_table = _tables.FirstOrDefault(e => e.Name == "User");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +30,9 @@ namespace XUnitTest.XCode.Code
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = _table,
|
Table = _table,
|
||||||
Namespace = "Company.MyName"
|
|
||||||
};
|
};
|
||||||
builder.Usings.Add("NewLife.Remoting");
|
builder.Option.Namespace = "Company.MyName";
|
||||||
|
builder.Option.Usings.Add("NewLife.Remoting");
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
|
||||||
|
@ -46,9 +49,9 @@ namespace XUnitTest.XCode.Code
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = _table,
|
Table = _table,
|
||||||
BaseClass = "MyEntityBase",
|
|
||||||
Partial = false
|
|
||||||
};
|
};
|
||||||
|
builder.Option.BaseClass = "MyEntityBase";
|
||||||
|
builder.Option.Partial = false;
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
|
||||||
|
@ -65,8 +68,8 @@ namespace XUnitTest.XCode.Code
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = _table,
|
Table = _table,
|
||||||
Pure = true
|
|
||||||
};
|
};
|
||||||
|
builder.Option.Pure = true;
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
|
||||||
|
@ -83,8 +86,8 @@ namespace XUnitTest.XCode.Code
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = _table,
|
Table = _table,
|
||||||
Interface = true
|
|
||||||
};
|
};
|
||||||
|
builder.Option.Interface = true;
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
|
||||||
|
@ -101,26 +104,29 @@ namespace XUnitTest.XCode.Code
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = _table,
|
Table = _table,
|
||||||
Pure = true,
|
|
||||||
Output = ".\\Output\\" + Rand.NextString(8)
|
|
||||||
};
|
};
|
||||||
|
var option = builder.Option;
|
||||||
|
option.Pure = true;
|
||||||
|
option.Output = ".\\Output\\" + Rand.NextString(8);
|
||||||
|
|
||||||
|
if (Directory.Exists(option.Output.GetFullPath())) Directory.Delete(option.Output.GetFullPath(), true);
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
|
||||||
var file = (builder.Output + "\\" + builder.Table.DisplayName + ".cs").GetFullPath();
|
var file = (option.Output + "\\" + builder.Table.DisplayName + ".cs").GetFullPath();
|
||||||
if (File.Exists(file)) File.Delete(file);
|
if (File.Exists(file)) File.Delete(file);
|
||||||
|
|
||||||
builder.Save();
|
builder.Save();
|
||||||
Assert.True(File.Exists(file));
|
Assert.True(File.Exists(file));
|
||||||
|
|
||||||
file = (builder.Output + "\\" + builder.Table.Name + ".xs").GetFullPath();
|
file = (option.Output + "\\" + builder.Table.Name + ".xs").GetFullPath();
|
||||||
if (File.Exists(file)) File.Delete(file);
|
if (File.Exists(file)) File.Delete(file);
|
||||||
|
|
||||||
builder.Save(".xs", false, false);
|
builder.Save(".xs", false, false);
|
||||||
Assert.True(File.Exists(file));
|
Assert.True(File.Exists(file));
|
||||||
|
|
||||||
// 清理
|
//// 清理
|
||||||
Directory.Delete(builder.Output.GetFullPath(), true);
|
//Directory.Delete(option.Output.GetFullPath(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -130,8 +136,14 @@ namespace XUnitTest.XCode.Code
|
||||||
var dir = ".\\Output\\Models\\";
|
var dir = ".\\Output\\Models\\";
|
||||||
if (Directory.Exists(dir.GetFullPath())) Directory.Delete(dir.GetFullPath(), true);
|
if (Directory.Exists(dir.GetFullPath())) Directory.Delete(dir.GetFullPath(), true);
|
||||||
|
|
||||||
ClassBuilder.BuildModels(_tables, dir, "Model");
|
var option = new BuilderOption
|
||||||
ClassBuilder.BuildInterfaces(_tables, dir, "Model");
|
{
|
||||||
|
Output = dir,
|
||||||
|
ClassPrefix = "Model"
|
||||||
|
};
|
||||||
|
|
||||||
|
ClassBuilder.BuildModels(_tables, option);
|
||||||
|
ClassBuilder.BuildInterfaces(_tables, option);
|
||||||
|
|
||||||
foreach (var item in _tables)
|
foreach (var item in _tables)
|
||||||
{
|
{
|
||||||
|
@ -149,8 +161,16 @@ namespace XUnitTest.XCode.Code
|
||||||
var dir = ".\\Output\\Dtos\\";
|
var dir = ".\\Output\\Dtos\\";
|
||||||
if (Directory.Exists(dir.GetFullPath())) Directory.Delete(dir.GetFullPath(), true);
|
if (Directory.Exists(dir.GetFullPath())) Directory.Delete(dir.GetFullPath(), true);
|
||||||
|
|
||||||
ClassBuilder.BuildModels(_tables, dir, "Dto");
|
var option = new BuilderOption
|
||||||
ClassBuilder.BuildInterfaces(_tables, dir);
|
{
|
||||||
|
Output = dir,
|
||||||
|
ClassPrefix = "Dto"
|
||||||
|
};
|
||||||
|
|
||||||
|
ClassBuilder.BuildModels(_tables, option);
|
||||||
|
|
||||||
|
option.ClassPrefix = null;
|
||||||
|
ClassBuilder.BuildInterfaces(_tables, option);
|
||||||
|
|
||||||
foreach (var item in _tables)
|
foreach (var item in _tables)
|
||||||
{
|
{
|
||||||
|
@ -168,15 +188,19 @@ namespace XUnitTest.XCode.Code
|
||||||
var dir = ".\\Output\\BuildTT\\";
|
var dir = ".\\Output\\BuildTT\\";
|
||||||
if (Directory.Exists(dir.GetFullPath())) Directory.Delete(dir.GetFullPath(), true);
|
if (Directory.Exists(dir.GetFullPath())) Directory.Delete(dir.GetFullPath(), true);
|
||||||
|
|
||||||
|
var option = new BuilderOption
|
||||||
|
{
|
||||||
|
Output = dir,
|
||||||
|
ClassPrefix = "TT"
|
||||||
|
};
|
||||||
|
|
||||||
// 测试Built.tt
|
// 测试Built.tt
|
||||||
foreach (var item in _tables)
|
foreach (var item in _tables)
|
||||||
{
|
{
|
||||||
var builder = new ClassBuilder
|
var builder = new ClassBuilder
|
||||||
{
|
{
|
||||||
Table = item,
|
Table = item,
|
||||||
Output = dir,
|
Option = option,
|
||||||
Pure = true,
|
|
||||||
ClassName = item.Name + "TT",
|
|
||||||
};
|
};
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
builder.Save(null, true, false);
|
builder.Save(null, true, false);
|
||||||
|
|
|
@ -13,22 +13,29 @@ namespace XUnitTest.XCode.Code
|
||||||
public class EntityBuilderTests
|
public class EntityBuilderTests
|
||||||
{
|
{
|
||||||
private IDataTable _table;
|
private IDataTable _table;
|
||||||
|
private BuilderOption _option;
|
||||||
|
|
||||||
public EntityBuilderTests()
|
public EntityBuilderTests()
|
||||||
{
|
{
|
||||||
var tables = EntityBuilder.LoadModels(@"..\..\XCode\Membership\Member.xml", out _);
|
var tables = EntityBuilder.LoadModels(@"..\..\XCode\Membership\Member.xml", _option, out _);
|
||||||
_table = tables.FirstOrDefault(e => e.Name == "User");
|
_table = tables.FirstOrDefault(e => e.Name == "User");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Normal()
|
public void Normal()
|
||||||
{
|
{
|
||||||
var builder = new EntityBuilder
|
var option = new BuilderOption
|
||||||
{
|
{
|
||||||
Table = _table,
|
|
||||||
ConnName = "MyConn",
|
ConnName = "MyConn",
|
||||||
Namespace = "Company.MyName"
|
Namespace = "Company.MyName"
|
||||||
};
|
};
|
||||||
builder.Usings.Add("NewLife.Remoting");
|
option.Usings.Add("NewLife.Remoting");
|
||||||
|
|
||||||
|
var builder = new EntityBuilder
|
||||||
|
{
|
||||||
|
Table = _table,
|
||||||
|
Option = option,
|
||||||
|
};
|
||||||
|
|
||||||
// 数据类
|
// 数据类
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
@ -53,11 +60,17 @@ namespace XUnitTest.XCode.Code
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GenericType()
|
public void GenericType()
|
||||||
{
|
{
|
||||||
|
var option = new BuilderOption
|
||||||
|
{
|
||||||
|
ConnName = "MyConn",
|
||||||
|
Namespace = "Company.MyName"
|
||||||
|
};
|
||||||
|
|
||||||
var builder = new EntityBuilder
|
var builder = new EntityBuilder
|
||||||
{
|
{
|
||||||
Table = _table,
|
Table = _table,
|
||||||
GenericType = true,
|
GenericType = true,
|
||||||
Namespace = "Company.MyName"
|
Option = option,
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.Execute();
|
builder.Execute();
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Company.MyName
|
||||||
[BindIndex("IU_User_Name", true, "Name")]
|
[BindIndex("IU_User_Name", true, "Name")]
|
||||||
[BindIndex("IX_User_RoleID", false, "RoleID")]
|
[BindIndex("IX_User_RoleID", false, "RoleID")]
|
||||||
[BindIndex("IX_User_UpdateTime", false, "UpdateTime")]
|
[BindIndex("IX_User_UpdateTime", false, "UpdateTime")]
|
||||||
[BindTable("User", Description = "用户", ConnName = "", DbType = DatabaseType.None)]
|
[BindTable("User", Description = "用户", ConnName = "MyConn", DbType = DatabaseType.None)]
|
||||||
public partial class User<TEntity> : IUser
|
public partial class User<TEntity> : IUser
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
|
|
Loading…
Reference in New Issue