I have an view patient
in mysql database, which consists of patient_info
and patient_documents
tables. View patient
:
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| id | int | NO | | 0 | |
| name | varchar(30) | NO | | NULL | |
| passport_data | char(11) | NO | | NULL | |
+---------------+--------------+------+-----+---------+-------+
Table patient_info
:
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| name | varchar(30) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
Table patient_documents
:
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| documents_id | int | NO | PRI | NULL | auto_increment |
| patient_id | int | NO | UNI | NULL | |
| passport_data | char(11) | NO | UNI | NULL | |
+---------------+--------------+------+-----+---------+----------------+
I want to keep getting of entities from view patient
, but change adding of Patient
entity to database via dbcontext in the next way: insert Patient
‘s attributes into patient_info
and patient_document
. How can I implement it? I thought it’s a good idea because it’d be possible to add extra hidden attributes to patient_info
by other types of users and these attributes won’t be read by anyone who doesn’t have an access to patient_info
(view patient
restricts getting attributes). Maybe I recreated the wheel here and there’s no sense in such approach?
Summary: how to override adding of entity Patient
to DbContext
as adding of it’s attributes to patient_info
and patient_documents
, but keep getting of patient info through view patient
?