Question

in the out of the project template solution (Dynamic Data Web Application), I have the model created and all is good. - Get the list of the tables, and the select edit etc.

But my database has linking tables that just contain forgien keys - so the list template just displays the fk value

diagram of the table

Is there away to combine the list of the row in the primary table with an inspection of another table based on the fk?

More akin to a join in SQL? but using Linq2Entity and the MetaModel?

Below is the List.aspx.cs - this seems to bind the standard grid to the entitydatasource, but this is to the current table as per the route in the MVC.

But as you can see i need to go and query the Person, Role and Link table via the model to get the other fields so that this would be useful. vstudio

PS want to try and keep this in LINQ2Entity if possible -trying to grok

the natural thing that I want to do is start to spin off new sql queries to go and retrive the values. But this is not in this idiom.

Was it helpful?

Solution

you can reference the metaModel via the dataContext

MetaModel refMetaModel = MetaModel.GetModel(typeof(yourdataContextName));
MetaTable refMetaModel;
refMetaModel =  refMetaModel.GetTable("yourTableName");

PS looked at your code and this works in your sceanrio. You can get the tables from the model then inspect the data returned for each table in the model

MSDN article on the MetaModel

OTHER TIPS

Uselful to use this as well from the Linq to Entities Model -

Using the dataContext - you can get the acutal data most useful.

The metaModel allows access to the dataModel which gives you the underlying ddl type information

//use the datacontext to get the underlying data
      using (brrdbEntities brr = new brr_dbEntities())
      {
          ObjectQuery<person> people = brr.person;
          IQueryable<string> names = from p in people select p.person_name;
          foreach (var name    in names)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top