Vishwakant Tripathi

Vishwakant Tripathi

  • 1k
  • 723
  • 841.9k

How to get data and columns from linq dynamically

Sep 2 2013 3:02 AM
Hi,
  I have a problem with linq in my scenario, where table name comes dynamically and i need to fetch all columns and records from that table. for example..
public void GetData(string tableName,int id)
{
DataClasses1DataContext _db = new DataClasses1DataContext();
 var qry = from o in _db.Organizations where o.OrganizationId==id select o;
//but here, I cannot pass Organizations table directly as It is dynamic
}

So how can I give table name dynamically in context, and how to get columns also for that table.
Please give me some idea.
Thanks




Answers (2)