063 Lookup resource Helper Class for PhbkEmployeeView - chempkovsky/CS82ANGULAR GitHub Wiki
- 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,LprEmployee01andLprEmployee02tables.- 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:
PhbkDbContextandLpEmpPhbkDbContext-
PhbkDbContextmust 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
-
LpPhBkControllersis the destination project-
Helpersis the destination folder
-
-
PhbkEmployeeViewis a View to generate the class -
01020-.lookupheper.cs- is a script type-
lookupheper.cs.t4is 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 codeLpEmpPhBkContextin 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
LpPhbkDbContextto 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,LprEmployee01andLprEmployee02tables must have a foreign keys, which referencePhbkEmployee-table. In additionLprEmployee02must have a foreign key, which referencesPhbkDivision-table... In short, find and replace-approach is optimal.