public string GetModelCode() { LTP.BuilderModel.BuilderModel model = new LTP.BuilderModel.BuilderModel(); model.ModelName = ModelName; model.NameSpace = NameSpace; model.Fieldlist = Fieldlist; model.Modelpath = Modelpath; return(model.CreatModel()); }
/// <summary> /// 得到Model类 /// </summary> //public string GetModelCode(string AssemblyGuid) //{ // //return model.CreatModel(); // imodel = BuilderFactory.CreateModelObj(AssemblyGuid); // if (imodel == null) // { // return "请选择有效的Model层代码组件类型!"; // } // imodel.ModelName = ModelName; // imodel.NameSpace = NameSpace; // imodel.Fieldlist = Fieldlist; // //imodel.Keys = Keys; // imodel.Modelpath = Modelpath; // //imodel.ModelSpace = ModelSpace; // return imodel.CreatModel(); //} /// <summary> /// 得到父子表Model /// </summary> public string GetModelCode(string tableNameParent, string modelNameParent, List <ColumnInfo> FieldlistP, string tableNameSon, string modelNameSon, List <ColumnInfo> FieldlistS) { if (modelNameParent == "") { modelNameParent = tableNameParent; } if (modelNameSon == "") { modelNameSon = tableNameSon; } StringPlus strclass = new StringPlus(); StringPlus strclass1 = new StringPlus(); StringPlus strclass2 = new StringPlus(); strclass.AppendLine("using System;"); strclass.AppendLine("using System.Collections.Generic;"); strclass.AppendLine("namespace " + Modelpath); strclass.AppendLine("{"); //父类 //LTP.BuilderModel.BuilderModelT modelP = new LTP.BuilderModel.BuilderModelT(dbobj, DbName, tableNameParent, modelNameParent, FieldlistP, // tableNameSon, modelNameSon, FieldlistS,NameSpace, Folder, Modelpath); LTP.BuilderModel.BuilderModelT modelP = new LTP.BuilderModel.BuilderModelT(); modelP.ModelName = modelNameParent; modelP.NameSpace = NameSpace; modelP.Fieldlist = FieldlistP; modelP.Modelpath = Modelpath; modelP.ModelNameSon = modelNameSon; //modelP.FieldlistSon = FieldlistS; strclass.AppendSpaceLine(1, "/// <summary>"); strclass.AppendSpaceLine(1, "/// 实体类" + modelNameParent + " 。(属性说明自动提取数据库字段的描述信息)"); strclass.AppendSpaceLine(1, "/// </summary>"); strclass.AppendSpaceLine(1, "public class " + modelNameParent); strclass.AppendSpaceLine(1, "{"); strclass.AppendSpaceLine(2, "public " + modelNameParent + "()"); strclass.AppendSpaceLine(2, "{}"); strclass.AppendLine(modelP.CreatModelMethodT()); strclass.AppendSpaceLine(1, "}"); //子类 //LTP.BuilderModel.BuilderModel modelS = new LTP.BuilderModel.BuilderModel(dbobj, DbName, tableNameSon, modelNameSon, NameSpace, Folder, Modelpath, FieldlistS); LTP.BuilderModel.BuilderModel modelS = new LTP.BuilderModel.BuilderModel(); modelS.ModelName = modelNameSon; modelS.NameSpace = NameSpace; modelS.Fieldlist = FieldlistS; modelS.Modelpath = Modelpath; strclass.AppendSpaceLine(1, "/// <summary>"); strclass.AppendSpaceLine(1, "/// 实体类" + modelNameSon + " 。(属性说明自动提取数据库字段的描述信息)"); strclass.AppendSpaceLine(1, "/// </summary>"); strclass.AppendSpaceLine(1, "public class " + modelNameSon); strclass.AppendSpaceLine(1, "{"); strclass.AppendSpaceLine(2, "public " + modelNameSon + "()"); strclass.AppendSpaceLine(2, "{}"); strclass.AppendLine(modelS.CreatModelMethod()); strclass.AppendSpaceLine(1, "}"); strclass.AppendLine("}"); strclass.AppendLine(""); return(strclass.ToString()); }