Paulconsulting
asked on
LINQ to SQL: Working with AttributeMappingSource is it possible to get the name of the table, then query the data for that table
In the code below I am populating a drop down list with the table names available in the configured LINQ to SQL model.
When I select a table name from the drop down list I want to select all of the data from that table and display it in a datagrid.
How can I do a dynamic LINQ query against a table name I get from the drop down list?
When I select a table name from the drop down list I want to select all of the data from that table and display it in a datagrid.
How can I do a dynamic LINQ query against a table name I get from the drop down list?
protected void BindPage()
{
var model = new AttributeMappingSource().GetModel(typeof (USFCMSDataContext));
ddlTables.DataSource = from m in model.GetTables() orderby m.TableName select m;
ddlTables.DataTextField = "TableName";
ddlTables.DataBind();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
LINQ To SQL is Dead - Read Between the Lines
http://codebetter.com/blogs/david.hayden/archive/2008/10/31/linq-to-sql-is-dead-read-between-the-lines.aspx
2) I haven't invested much time learning about something that might be deprecated.
3) What kind of LINQ query are you looking for?
4) What information are you trying to get?
LINQ query to get all the column names in the DBML tables
http://cubicthoughts.com/2008/10/31/linq-query-to-get-all-the-column-names-in-the-dbml-tables/