mardi 17 décembre 2019

C# - Dealing with representation of an object in two different tables

I'm dealing with a possibly uncommon case. I have a project in C# (net framework 4.7.2) that acts as a broker for two different tables (in different SQL servers).

The two tables represent the same thing; Let's call it "Person". I wanted to try and map this Person as an Object.

Database 1
CREATE TABLE Person_A (
    PersonA_ID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255),
    A_Column_1 varchar(255),
    A_Column_2 varchar(255)
);

Database 2
CREATE TABLE Person_B (
    PersonB_ID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255),
    B_Column_1 varchar(255),
    B_Column_2 varchar(255)
);

The Person_A row is the same as Person_B if they share the same "Last Name", "First Name", "Address" and "City".

So far I'm using ADO.net queries and returning DataTables, with no object mapping whatsoever. This project is heavy on the queries (a lot of Inserts, Deletes, Updates), and from what I've read so far, using EF wouldn't be a good idea because of the overhead.

So far I've read that Dapper might be a good idea for retrieving the objects from both tables and then maybe using AutoMappper to create the relationship between PersonA and personB. Is this a possible solution? Would the Query Object Design Pattern be useful here?

Aucun commentaire:

Enregistrer un commentaire