Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using MVC4 r.
I wanted to have single model class that contains 3 transactional tables so that when I create strongly-typed create page I can display in the data entry the 3 tables (txn_RequestForm , txn_list_IndividualUser, txn_list_MultipleUsers er).

1. list_ddlRequestType RequestTypeID 1(Individual User) & 2 (Multiple User)
2. txn_RequestForm (RequestID) PK :
3. txn_list_IndividualUser (RequestID) FK
4. txn_list_MultipleUsers (RequestID) FK grid


VB
txn_RequestForm
RequestID (PK)  RequestTypeID (FK)  ContactNumber
1   1   5566
2   2   5567
3   2   1234



txn_list_IndividualUser 					
RequestID (FK) |EmpNo	|FirstName	|LastName	|EmailAdd	
1	|105514	|Juan	|Pedro	|juan.email@teSTmvc.COM	
1	|105515	|Juan_2	|Pedro_2	|juan.email2@teSTmvc.COM

txn_list_MultipleUsers				
RequestID(FK)	MUserID 	NameSurname 	PurposeID 	MPositionTitle
3	|43211	|Joshua_1	|_1	|_Test
3	|43212	|Joshua_2	|_2	|_Test
3	|43213	|Joshua_3	|_3	|_Test


Thanks in advance.
Posted
Updated 24-Sep-12 21:32pm
v3
Comments
CodeHawkz 24-Sep-12 5:59am    
Hey there,

Firstly, your question is not clear at all. I understand that you might have sensitive data in your tables, by all means remove them. But please, do change them to something we can understand (e.g.: to an example which shows some logical relationship).

Secondly, I believe your problem can ideally be solved at a SQL level (or database level), if I am not mistaken.

If you elaborate more on your problem, am sure someone would be able to answer you faster.

Regards

1 solution

You can only point a grid type control at a single data source. So you'll need to create a model class that encapsulates the behaviour you are talking about (picking rows from T2 or T3 as appropriate and exposing a List or Queryable of the appropriate type).

If you have control of the database, if T2 and T3 have the same schema then you probably want to consider making them a single table with a type-switching column. Then you can just do a normal foreign key lookup from T1 based on ID and type, instead of doing a lookup based on ID and then switching between rows from different tables. The database model isn't really designed to do that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900