2
Answers

How to get data and columns from linq dynamically

Ask a question
Vd Tripathi

Vd Tripathi

11y
2.3k
1
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)