using System.Collections.Generic;
public class TableConverter
public static string ConvertTableToCSharpProperties(string tableData)
if (string.IsNullOrEmpty(tableData))
var properties = new StringBuilder();
var rows = tableData.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var row in rows)
var columns = row.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var variableName = columns[0];
var mssqlType = columns[1];
var transformedName = TransformVariableName(variableName);
var csharpType = MapMssqlToCSharpType(mssqlType);
var propertyName = GeneratePropertyName(transformedName);
var propertyString = $"public {csharpType} {propertyName} {{ get; set; }}";
properties.AppendLine(propertyString);
Console.WriteLine($"Error processing row: {row}. Error: {ex.Message}");
return properties.ToString().TrimEnd();
private static string TransformVariableName(string variableName)
var result = new StringBuilder();
result.Append(char.ToUpper(variableName[0]));
for (int i = 1; i < variableName.Length; i++)
if (char.IsUpper(variableName[i]))
result.Append(variableName[i]);
return result.ToString();
private static string MapMssqlToCSharpType(string mssqlType)
switch (mssqlType.ToUpper())
throw new ArgumentException($"Unsupported MSSQL data type: {mssqlType}");
private static string GeneratePropertyName(string transformedName)
var words = transformedName.Split(' ');
var propertyName = new StringBuilder();
foreach (var word in words)
if (string.IsNullOrEmpty(word)) continue;
if (!char.IsLetter(word[0]))
throw new ArgumentException($"Invalid character at the beginning of word: {word}");
propertyName.Append(char.ToUpper(word[0]));
propertyName.Append(word.Substring(1));
if (!char.IsLetter(propertyName[0]))
throw new ArgumentException($"Property name must start with a letter.");
return propertyName.ToString();
public static void Main(string[] args)
string tableData = @"employeeId INT 1
string cSharpProperties = ConvertTableToCSharpProperties(tableData);
Console.WriteLine(cSharpProperties);