Linq to Entity - can i get to another table in the model when in the list template MVC page

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

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.

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.

Answers


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


Need Your Help

Mobile Safari Fixed Position Footer Problems

jquery mobile-safari positioning css-position sticky-footer

How do you get a mobile safari fixed position footer to stay where it belongs and not bounce?

Exclude property from getType().GetProperties()

c# .net reflection

Hi i'm working in a class library using C#, and i have some classes with some properties.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.