081 Lookup resource Helper Class for PhbkPhoneView - 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
LpdPhone,LprPhone01,LprPhone02,LprPhone03andLprPhone04tables.- 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:
PhbkDbContextandLpPhnPhBkContext-
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
-
-
PhbkPhoneViewis a View to generate the class -
01020-.lookupheper.cs- is a script type-
lookupheper.cs.t4is a t4 script
-
-
phbk-phone-view.lookupheper.cs- file will be created
Click to show the picture

- We need to make modifications of the
phbk-phone-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 codeLpPhnPhBkContext dbin 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-phone-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,LprPhone01, ...,LprPhone04tables must have a foreign keys, which referencePhbkPhone-table. In additionLprPhone04must have a foreign key, which referencesPhbkEmployee-table... In short, find and replace-approach is optimal.