I am struggling with whether or not to use a TypedView or Collection of entities. Here is a simplified, contrived example of my problem:
I have a table of Foos...a bunch of them...and lets say Foo has columns TypeId, StateId, StatusId...whatever where each of these keys is a foreign key into another table with a description column describing what TypeId 1 and such is. Pretty standard stuff.
Now, in my UI I want to display a list (crap-load) of Foos. Obviously I don't want to display TypeId but the description form Type table, same goes for all other foreign key columns. Now,...I could, and have (it is my current solution) create a database view/TypedView that joins all the stuff up nicely and display that which seemed a perfectly acceptable solution at the time. But, the problem with it is: Lets say a user selects Foo[x] from my nice list and wants to view/edit its properties in a new details window. It would be nice if I could send the new window a reference to Foo[x] to edit but obviously that is not going to work as Foo[x] is of type FooTypedViewRow rather than type FooEntity. So what I have been doing is passing Foo[x].PK to the new window and fetching the entity doing some work on it and saving it. Lets say I change Foo[x].Title in the window. Now my List is inconsistent from the actual data so I would have to re fetch the typed view to keep things consistent. Please tell me there is a better way.
What I would like to do is have my List be a collection of FooEntities that way when I updated Foo[X] the list would be updated as well so I would not have to 1. fetch Foo[x] 2. have to reload the list if Foo[x] was edited. That said I cannot exactly bind my list (again huge list) to a FooCollection and call Foo.Type.Desctiption everytime I row loads into the view.
An example...
MyList.Datasouce = FooHelper.GetAllFoos();
OnRowCreated(EventArgs e)
{
e.Columns["Type"] = Foo.Type.Description; //Call to database (lazy load) right?
e.Columns["State"] = Foo.State.Description; //Call to database
e.Columns["Status"] = Foo.Status.Desctiption; //Call to database
...
}
//(3 db calls per row) * (crap-load of rows) = too long to load right?
I am sure that this issue has been solved 300,000,000 times. Am I missing something here? How do you guys do it?