Go Back

RIA and Entity Framework Basic Requirements?

So, the promise of RIA and the Entity Framework is to make common Line of Business Application development simpler, right? Yet there is an incredibly basic scenario that has me stumped – am I alone here in having an application with lookup fields like State or Gender? Here is the setup:

We have rows of data (County entities) that reference another entity (States). These are both in our Entity Framework model. I.e the State is a lookup table for county (it could just as well be a gender table for a person, or some other lookup table relationship).

We want to show the County rows in a Grid (a standard one will do), but obviously not the StateID: we want the State name, for instance:

County                 State     SomeOtherCol  
Watsonville        CA          12.3  
Monterey           CA          34.0    
Emeryville           NY          2.01    

Note, that State.Name is not part of County, County just has a reference to a State, which has a Name. Also, we do not need in place editing in the grid.  We just want to show the State Name instead of the State ID, even though that is not an attribute of County.

When you click on a row in the grid, say Monterey, we want to show the data for that row in a DataForm under the grid, and we want state to be shown as a DropDownList of States (bound to a State DomainDataService):

image

Furthermore, we want to

  1. Have it initially show the current state (CA) for the selected record
  2. Allow you to change state by choosing a different item
  3. Save the changes.

Bizarrely, this doesn’t work, nor can we find anyone who has figured it out. Is it a problem in the Grid?  When we put a drop down list here, when you change from one state to another for a record, it changes the states on all the rows that have that state…! So instead we have to put a textbox there and have the user type the State ID! Not good…

Again, note that we do not wish to show the County or State IDs anywhere in the UI.

To make it more interesting,

  • If we fetch 100 County rows all with the same State, we obviously only want to include one instance of that State object in the fetch from the database and over the wire in WCF, and all we really need is the state name, not the full state entity here…
  • We want to fetch the full list of States once and only once to populate the States drop down

Seems like a 101 level piece of functionality, if we could get someone to point us in the right direction.

We have all kinds of hacks in place, including using converters in the grid to translate from ID to Name on the state, but none of this is satisfactory. Am I missing something in the big picture? All I can find is examples on Master Detail, but that isn’t quite what is going on here, this is about lookup fields. Is there someone with experience that spans RIA, DataForms, Grids and EF that can put the puzzle pieces together?

Anyone?

  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark
Post a comment!
  1. Formatting options