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
Loading

Kunal VaishyaPosted Sep 2, 2013, 3:55 AM
try this its very help full
http://romiller.com/2012/04/20/what-tables-are-in-my-ef-model-and-my-database/
Posted Sep 2, 2013, 3:53 AM
1) Use Expression trees
http://msdn.microsoft.com/en-us/library/vstudio/bb882637.aspx
2) Use ObjectQyery.
http://msdn.microsoft.com/en-us/library/bb345303.aspx
string queryString = @"SELECT VALUE product FROM " + tableName +"AS reseultset";
// Call the constructor with the specified query and the ObjectContext.
ObjectQuery
foreach (var result in resultset)
{//Process the the items here
}