042 Lookup resource Helper Class for PhbkDivisionView - chempkovsky/CS82ANGULAR GitHub Wiki
- Create the Helpers folder to LpPhBkControllers project
- Run JavasScripts Wizard
- First page of the Wizard
- Second page of the Wizard
- Third page of the Wizard
- Fourth page of the Wizard
- Fifth page of the Wizard
- Sixth page of the Wizard
- Open generated file
- Now we need the code, which updates Lookup resource database, i.e. we need the implementation of the Add, Update, Delete methods for the
LpdDivision
,LprDivision01
andLprDivision02
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
andLpPhbkDbContext
-
PhbkDbContext
must be used to generate generate Lookup resource Helper Class
-
- with Visual Studio add
Helpers
-folder to LpPhBkControllers project
Click to show the picture
- To generate helper class
- Run Visual Studio and Open PhonebookSolution solution
- Right Click
Helpers
of theLpPhBkControllers
-project and selectJavasScripts Wizard
menu item to open the Wizard dialog
Click to show the picture
- On the first page of the dialog the destination folder is shown. The destination folder is the folder in which the generated file will be created. Click
Next
-button
On the second page of the Wizard we select DbContext that will be used to choose the entity for the View. Select PhBkContext.csproj and the PhBkContext class using the drop-down lists. Click Next
-button.
Click to show the picture
- On the third page of the Wizard
- select the View for which we need to generate the script
- in our case we have selected
PhbkDivisionView
-View
- in our case we have selected
- select the View for which we need to generate the script
Click to show the picture
- On the Fourth page of the Wizard select
01020-.lookupheper.cs
-script type and clickNext
-button
Click to show the picture
- On the Fifth page of the Wizard select
lookupheper.cs.t4
-script and clickNext
-button
Click to show the picture
- On the Sixth page of the Wizard click
Save
-button. close the Wizard -
phbk-division-view.lookupheper.cs
-file will be created.
Click to show the picture
- We need to make modifications of the
phbk-division-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 codeLpPhbkDbContext db
in thephbk-division-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-division-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,LprDivision01
andLprDivision02
tables must have a foreign keys, which referencePhbkDivision
-table. In additionLprDivision02
must have a foreign key, which referencesPhbkEnterprise
-table... In short, find and replace-approach is optimal.