locked
dynamic data with EF lookup issues RRS feed

  • Question

  • User-2027556735 posted

    I am using dynamic data in VS2013 with EF6.  I have installed the nuget packages Dynamic Data EF provider and the EntityDataSource control.  Site works great.

    Now I want to modify the templates to make the following possible:

    Take an example table called MainTable, TableOne, and TableTwo.  MainTable has a Primary Key and 2 columns:  Scope and ScopeLookup.

    If the value in MainTable.Scope  is 1 then the ScopeLookup value is a value in TableOne.

    If the value in MainTable.Scope  is 2 then the ScopeLookup value is a value in TableTwo.

    I have enumerated the Scope to an external enumeration so the Website is showing as a dropdown, but how would I tell EF to look at a different table in my model based on the value of column scope?

    Or is this not really a candidate for Dynamic Data ASP.Net?

    Friday, December 12, 2014 1:03 PM

Answers

All replies

  • User1759999623 posted

    If you're using information from the database to make this work, then you probably should do this all in the database.  You might consider a view that would contain a UNION between TableOne when MainTable.Scope is 1 and TableTwo when MainTable.Scope is 2, assuming that there is a relationship between MainTable and TableOne/TableTwo.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 12, 2014 4:06 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 14, 2014 5:38 PM
  • User-2027556735 posted

    Thanks for leading me in the correct direction.  I found your nuget package and installed the Dynamic Data Cascade Filters and Field templates in the dynamic data website project.  Installed NotAClue Dynamic Data Extensions in the project with the Entity Data Model.  In that project I have a class EntityMetaData.cs which contains all of the meta data info for my tables where I may decorate the classes with attributes like ScaffoldTable and your Cascade.  Everything compiles and runs, but it doesn't seem to be creating a dependency.  I tried to change the AutoPostback = "true" on the CascadingForeignKey_Edit control, but I cant seem to get the event to fire upon creation of a new row.  Any Ideas?

    Thursday, December 18, 2014 9:23 AM
  • User-2027556735 posted

    Is there something I should do because I am trying to span two different projects...One for the Entity model and one for the website?

    Thursday, December 18, 2014 9:26 AM
  • User1759999623 posted

    The Dynamic Data features are for your website where your entity model would be used as your model resource.

    Thursday, December 18, 2014 9:43 AM
  • User-2027556735 posted

    my entity model is not in my website. My dynamic data website works but not with the cascading fields.  The application has an admin configuration that I am using the DD website for, so I wanted to re use the model for other projects as well (therefore a separate project)

    Is that the problem?

    Thursday, December 18, 2014 9:53 AM
  • User-330204900 posted

    is you send me a message with you e-mail I can send you a working sample.

    Thursday, December 18, 2014 1:25 PM