Ejemplo n.º 1
0
        public static string TemplateService(TableInfo Table, string ServiceNameSpace, string EntityNameSpace)
        {
            StringBuilder codestring = new StringBuilder(@"using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YiFen.Core;
using YiFen.DataHelper;
");
            codestring.Append("using ").Append(EntityNameSpace).Append(";\r\n\r\n");
            codestring.Append("namespace ").Append(ServiceNameSpace).Append("\r\n{\r\n");
            codestring.Append("public class  ").Append(Table.Name).Append("Service : YiFen.DataHelper.Service<").Append(Table.Name).Append("Entity>\r\n{");
            codestring.Append("\r\n}\r\n}");
            return codestring.ToString();
        }
 TableInfo GetTableInfo(string ConnectionString, string TableName)
 {
     TableInfo table = new TableInfo();
     table.Name = TableName;
     string sql = "SELECT TOP 1 * FROM [" + TableName + "]";
     using (SqlDataReader rd = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, sql))
     {
         for (int i = 0; i < rd.FieldCount; i++)
         {
             FieldInfo field = new FieldInfo();
             field.Name = rd.GetName(i);
             field.DbType = rd.GetFieldType(i);
             table.Fields.Add(field);
         }
     }
     return table;
 }
Ejemplo n.º 3
0
        public static string TemplateEntity(TableInfo Table, string NameSpace)
        {
            StringBuilder codestring = new StringBuilder(@"using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using YiFen.DataHelper;
");
            codestring.Append("namespace ").Append(NameSpace).Append("\r\n{\r\n");
            codestring.Append("public class  ").Append(Table.Name).Append("Entity : YiFen.DataHelper.Entity\r\n{");
            foreach (FieldInfo field in Table.Fields)
            {
                codestring.Append(TemplateEntity(field));
            }
            codestring.Append("}\r\n}");
            return codestring.ToString();
        }