using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetTableNameandColumnName
{
class Program
{
static void Main(string[] args)
{
DataClasses1DataContext context = new DataClasses1DataContext();
#region All Tables Name
var dataModel = context.Mapping.GetTables();
foreach (var r in dataModel)
{
Console.WriteLine(r.TableName);
}
Console.ReadKey(true);
#endregion
#region Columns Name of Person table
foreach (var r in dataModel)
{
if (r.TableName.Equals("dbo.Person", StringComparison.InvariantCultureIgnoreCase))
{
foreach (var r1 in r.RowType.DataMembers)
{
Console.WriteLine(r1.MappedName);
}
}
}
#endregion
Console.ReadKey(true);
}
}
}
Follow @debugmode_
*********************************
Discover more from Dhananjay Kumar
Subscribe to get the latest posts sent to your email.












How do you select multiple table names with — if (r.TableName.Equals(“dbo.Person”, StringComparison.InvariantCultureIgnoreCase))
using checkedlistbox to populate multiple tablenames columns?