public string GenerateInfoClassFromDataTable(DataTable table, string ClassName) { StringBuilder strBuilder = new StringBuilder(); strBuilder.Append("\t"); strBuilder.Append("public class "); strBuilder.Append(ClassName); strBuilder.Append(USUtil.R); strBuilder.Append(USUtil.T_OpenBracket); foreach (DataColumn dc in table.Columns) { strBuilder.Append(USUtil.NTT); strBuilder.Append(" public "); string SystdataType = dc.DataType.ToString(); strBuilder.Append(GetDataTypeBySystemDataType(SystdataType)); strBuilder.Append(" "); string strColName = dc.ColumnName; strColName = USUtil.CovertFirstLetterToCapital(strColName); strBuilder.Append(strColName); strBuilder.Append(" "); strBuilder.Append(" { get; set; }"); } strBuilder.Append(USUtil.R); strBuilder.Append(USUtil.T_CloseBracket); return(strBuilder.ToString()); }
public string GetTableInfoByTableNameandClassName(AdonaiBuildStructureInfo buildInfo) { string tableName = USUtil.CovertFirstLetterToCapital(buildInfo.TableName); string infoClassName = USUtil.CovertFirstLetterToCapital(buildInfo.InfoClassName); string strFinalinfoString = string.Empty; string strScript = SmartBuilder.Repository.MsSQL.QueryCollaborator.GenerateQuery_GetListOfColumnInfoByTableName(tableName); AppUtilityDataProvider objInfoDataProvider = new AppUtilityDataProvider(); DataTable dataTable = objInfoDataProvider.GetTableColumnsBySQLScritpt(strScript, buildInfo.ConnectionString); InfoClassGenerator infoClassGenerator = new InfoClassGenerator(GetSystemSettings()); strFinalinfoString = infoClassGenerator.BuildInfoClassforGivenDataTable(dataTable, infoClassName, buildInfo.IsNullableRequired, buildInfo.IsSerializable); //Process data of data table to build final string for the C# info class //strFinalinfoString = TableInfoGenerator.BuildInfoClassforGivenDataTable(dt, infoClassName, buildInfo.IsNullableRequired, buildInfo.IsSerializable); StringBuilder strBuilder = new StringBuilder(); strBuilder.Append(USUtil.LoadUsingCodex(buildInfo.InfoNameSpace, string.Empty)); strBuilder.Append(strFinalinfoString); strBuilder.Append(" \r }"); USUtil.CreateClassFileForGivenTypeClass(infoClassName, strBuilder.ToString(), ICD.Info); //Add Controller Class if (buildInfo.IsControllerRequired) { strBuilder.Append(AddContentHeader("Your Controller Class")); string txtControllerCode = USUtil.Initialize_UsingStatementAndClassHeader(buildInfo.InfoNameSpace, tableName, ICD.Controller); USUtil.CreateClassFileForGivenTypeClass(tableName + USUtil.Controller, txtControllerCode, ICD.Controller); strBuilder.Append(txtControllerCode); } //Add SQL DataProvider Class if (buildInfo.IsProviderRequired) { strBuilder.Append(AddContentHeader("Your SQL Data Provider Class")); string txtProviderCode = USUtil.Initialize_UsingStatementAndClassHeader(buildInfo.InfoNameSpace, tableName, ICD.DataProvider); USUtil.CreateClassFileForGivenTypeClass(tableName + USUtil.Provider, txtProviderCode, ICD.DataProvider); strBuilder.Append(txtProviderCode); } return(strBuilder.ToString()); }