?
Solved

LINQ to SQL: Working with AttributeMappingSource is it possible to get the name of the table, then query the data for that table

Posted on 2009-05-15
2
Medium Priority
?
912 Views
Last Modified: 2013-11-08
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?
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();
        }

Open in new window

0
Comment
Question by:Paulconsulting
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24402535
1) Is LINQ to SQL really dead?

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/
0
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 1000 total points
ID: 24406071
1. Companies that have invested time and development expense are not going to just switch over to Entity Framework because Microsoft says so. I know of plenty of companies still building applications in VB6. Depends on how you define "dead" I suppose. Besides which, Entity Framework still uses LINQ-style queries.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question