-
Notifications
You must be signed in to change notification settings - Fork 0
063 Lookup resource Helper Class for PhbkEmployeeView
- Now we need the code, which updates Lookup resource database, i.e. we need the implementation of the Add, Update, Delete methods for the
LpdEmpLastName
,LpdEmpFirstName
,LpdEmpSecondName
,LprEmployee01
andLprEmployee02
tables.- with
01020-.lookupheper.cs
-Wizard's script we generate Lookup resource Helper Class which implements Add, Update, Delete methods.
- with
- we have two Database contexts:
PhbkDbContext
andLpEmpPhbkDbContext
-
PhbkDbContext
must be used to generate generate Lookup resource Helper Class
-
- We do not describe step by step instructions
- please repeat the steps similar to those described in the article 042
-
LpPhBkControllers
is the destination project-
Helpers
is the destination folder
-
-
PhbkEmployeeView
is a View to generate the class -
01020-.lookupheper.cs
- is a script type-
lookupheper.cs.t4
is a t4 script
-
-
phbk-employee-view.lookupheper.cs
- file will be created
Click to show the picture
- We need to make modifications of the
phbk-employee-view.lookupheper.cs
-file
-
replace the
using PhBkEntity.PhBk;
-line with theusing LpPhBkEntity.PhBk;
-
replace the
using PhBkContext.PhBk;
-line with theusing LpPhBkContext.PhBk;
-
replace the
PhbkDbContext db
-code with the codeLpEmpPhBkContext
in thephbk-employee-view.lookupheper.cs
-file -
Note: The Lookup resource Helper and Consumer Classes are the only two classes that need to be modified after generation. We can not use
LpPhbkDbContext
to generatephbk-employee-view.lookupheper.cs
-file. Without additional foreign keys, the Wizard will not be able to recognize the group of tables as a lookup resource. To be recognizable as a lookup resource,LprEmployee01
andLprEmployee02
tables must have a foreign keys, which referencePhbkEmployee
-table. In additionLprEmployee02
must have a foreign key, which referencesPhbkDivision
-table... In short, find and replace-approach is optimal.