Last post Sep 11, 2010 07:13 PM by sjnaughton
Sep 09, 2010 06:58 PM|SethA|LINK
I'm working with a legacy database that is not normalized, nor can i change it to normalize it and/or add relationships. I've successfully got my List and Details pages up and running and am now moving on to insert/edit. Here's my challenge:
The insert page needs to accept data that will be written to multiple tables (i.e. consider a customer call where we're creating the customer, the customer address record, etc. on the fly). In addition, the customer can either be a "customer" or a "prospect",
each being a separate table.
Any suggestions as the best approach to tackling this issue. My gut feel is that I should write a standard aspx page and hook up the data manually. Not sure how to navigate to this page from the insert / edit button (modified routing).
Sep 09, 2010 11:27 PM|klca|LINK
I will try to answer with a couple of questions:
I don't know why you can't normalize your data even tough it might have millions of records. Linq/Entity models (O/RM models: Object Relational Mapping) will do a lot for you in pursuing fixing your legacy data data (that because of the lack of referential
integrity) might have a lot of inconsistencies.
Anyway, the only problem you might have is a lot of orphan records and a lot of data that it would be much better and conveniently fixed somehow (duplicated records, non single keys in tables, etc.) by Q.C. and accounting people. Someday they will have to
certifiy that database ... I guess, uh?
If your problem in normalizing can't be done because of using a legacy application too, then I would understand why are you trying using Dynamic Data to get a newer approach in maintaining your database quickly with a new set of programs.
I understand (it is a luck) that VS2010 allows you to have a different schema database from the one you might create using the O/RM tool (DataContex). In the designer you can add as many relationships as needed (even tough
they don't exist at all in your database schema) and it has a tool that will generate for you the new script for creating a new database schema already normalized.
What I don't know is this: suppose you create a new database architechture and based on that DataContext you generate a Dynamic Data application. ... .... ... then ... .... How it is going to work while CRUDing your legacy database with the Dynamic Data
GUI data into your non-normalied model?
Probably you will have to build a lot of busines rules as to make CRUD not to fail ... that means that you MUST create every single rule derived from linking tables into source code of any kind: MetaData, SPs, classes, controls, validations, etc.
Carlos Porras (El Salvador)
Sep 10, 2010 07:54 AM|sjnaughton|LINK
Hi SethA, I would normally do this sort of thing in DD using a view and then using SPROC's to do the inserts and you can't do that so I would use trditional ASP.Net sorry.
Sep 10, 2010 10:35 AM|SethA|LINK
Let's say I create a view to grab the unnormalized data, which I definitely can do. Can I associate the view with the insert/edit action from my main list? I'm pretty sure I can, based on the videos, just want to confirm. Also, if both my insert and edit
pages display the same fields, but the edit page marks some of those fields as read only, do I need to create separate custom classes so I can decorate the fields with the required attributes. One example would be:
On insert, I need to prompt for full address information; however, on edit, the address information is read-only.
Sep 11, 2010 05:47 AM|sjnaughton|LINK
Hi Seth How I do this is I add the View to me Model (usually Liqn to SQL) and then add association to the tables I need then I map SPROCS to do Insert Update and Delete.
See Rick Andersons explination of adding an updateable view
How to create an updateable view with ADO Entity Framework and with LINQ to SQL (I usually just set the relavent column as PK sometimes it tow columns to make it unique).
Sep 11, 2010 12:16 PM|SethA|LINK
Thanks. The blog has been moved to http://blogs.msdn.com/b/rickandy/archive/2008/10/04/how-to-create-an-updateable-view-with-ado-entity-framework.aspx.
I'll give it a whirl and let you know. Right now, I'm under a bit of a time crunch so I'll probably write an ASPX page for insert and edit, and use DD to do my lists, etc.
Sep 11, 2010 07:13 PM|sjnaughton|LINK
Hi Seth, I fixed my link sometimes when you paste a link in the domain gets cropped oof [:(]