using System; using DotNet.Framework.DataAccess.Attribute; using System.Data; namespace MyProject.Entities { <# string connectionString = "Data Source=localhost;Initial Catalog=EDNFramework;User ID=sa;pwd=as"; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); System.Data.DataTable schema = conn.GetSchema("TABLES"); string selectQuery = "select * from @tableName"; SqlCommand command = new SqlCommand(selectQuery,conn); SqlDataAdapter ad = new SqlDataAdapter(command); System.Data.DataSet ds = new DataSet(); foreach(System.Data.DataRow row in schema.Rows) { #>
public class <#= row["TABLE_NAME"].ToString()#> {<# ds.Tables.Clear(); command.CommandText = selectQuery.Replace("@tableName",row["TABLE_NAME"].ToString()); ad.FillSchema(ds, SchemaType.Mapped, row["TABLE_NAME"].ToString()); foreach (DataColumn dc in ds.Tables[0].Columns) {#>