Re: Object Relational Mapper with deep copy ability?
- From: "W.G. Ryan MVP" <WilliamRyan@xxxxxxxxxxxxxxxx>
- Date: Fri, 16 Sep 2005 11:24:31 -0400
You may want to ask the sources directly (the two best ORM tools I know of
are LLBLGenPro and Deklarit). Frans is a regular in this group. frans can
be reached here http://weblogs.asp.net/fbouma and Andres can be reached
here http://weblogs.asp.net/aaguiar. I'd run it for you and answer you
directly but I'm a little busy at the moment, however I'd run it by them and
see how their products handle it. Admittidely, I am friends with both of
them (just wanted to make that known up front) but my advice is as objective
as I can be here and has nothing to do with being buddy's. Either tool, I'm
quite sure, can handle what you need and are nothing short of wonderful.
HTH,
Bill
"Josh" <JGough@xxxxxxx> wrote in message
news:1126814899.690601.203110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Greetings, all.
>
> I'm looking at some of the existing ORM tools to see if they might help
> me create a reusable solution to this problem. I want to be able to
> copy a record and all of its foreign key related records from one
> physical DB to another, but I also need to be able to modify the IDs of
> the child records before performing the insertions.
>
> For example:
>
> In a production app I may have this table:
>
> Person:
>
> person_id PK
> fname
> lname
>
> Report:
>
> report_id
> contributor_id (FK on Person)
> title
> submitdate
>
> ReportHistory:
>
> history_id PK
> report_id FK
> person_id
> action_type (FK on a Lookup table...)
> action_date
>
> When I perform the copy, I want to take all the non-key data from
> Report and ReportHistory, but include some type of mapping to translate
> the person_id and contributor_id into something else, as defined by a
> user.
>
> The reason for this is that we want to be able to move data from a
> production environment to a testing environment and keep the structure
> basically the same, but translate the sensitive production information
> into test data.
>
> Does anyone know a good reusable way to achieve this? I just got
> through looking at Olero ORM.net, but I didn't see an ability to do a
> deep copy of the data.
>
>
> I'm thinking of some pseudo-code like this:
>
> DataManager dmSource = new DataManager(connStringSrc);
> DataManager dmDest = new DataManager(connStringDest);
>
> Report rptSource = manager.GetReportById(23);
> Report rptDest = rptSource.DeepCopy();
>
> foreach (ReportHistory history in rptDest.ReportHistoryCollection)
> {
> history.person_id =
> my_custom_mapping_function_goes_here(history.person_id);
> }
>
> etc...
> In the real situation, there are about 10 child tables.
>
> rptDest.DataManager = dmDest;
> rptDest.Insert(); // or something like this....
>
> The main requirements being:
>
> - The ability to turn off all triggers during the insert.
> - The ability to retrieve all foreign-key related records from a parent
> record.
> - The ability to make a deep copy of the collection that is decoupled
> from the original datasource conenction.
> - The ability to at then iteratively insert/update all child related
> records back to a different target data source.
>
> I thought at first glance the XSD designer in VS 2005 should be able to
> do this, but when I tried to do a obj.GetsomeforeignkeyTableRows() it
> told me the cast was invalid.
>
> I think this can be done in T-SQL also with some "insert into ...
> select" statements, but I don't think it is as reusable or robust as
> being able to do it from code.
>
> Thanks!
> Josh
>
.
- Follow-Ups:
- Prev by Date: Long string common practice
- Next by Date: Re: How to update a dbf table without using primary key
- Previous by thread: Long string common practice
- Next by thread: Re: Object Relational Mapper with deep copy ability?
- Index(es):
Relevant Pages
|