简体   繁体   中英

Merging entities in Entity Framework

I have two sets of identical SQL tables both belonging to separate schemas, one is the default [dbo] the other is [staging]. Data comes through to the staging schema via a web service, every operation is an insert, and no updates occur.

As the data comes through to staging, I would like to find the record in the [dbo] tables and update all fields with what has come through (including the properties for all related child entities). If no matching records are found (based on a non-primary key but unique field) I would then create the relevant records (entities).

Is there a way to achieve this merging of records from the two schemas without manually pairing up fields from the two schemas?

I've in the past used Reflection to pair up the properties of two like entities. I don't really know of any better way than to loop the Properties of the type and set the target entity to the values of the source entity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM