063 Lookup resource Helper Class for PhbkEmployeeView - chempkovsky/CS82ANGULAR GitHub Wiki

Notes

  • 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 and LprEmployee02 tables.
    • with 01020-.lookupheper.cs-Wizard's script we generate Lookup resource Helper Class which implements Add, Update, Delete methods.
  • we have two Database contexts: PhbkDbContext and LpEmpPhbkDbContext
    • PhbkDbContext must be used to generate generate Lookup resource Helper Class

Steps required to accomplish the task

  • 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

Open generated file

Click to show the picture

project structure

  • We need to make modifications of the phbk-employee-view.lookupheper.cs-file
Find and replace
  • replace the using PhBkEntity.PhBk;-line with the using LpPhBkEntity.PhBk;

  • replace the using PhBkContext.PhBk;-line with the using LpPhBkContext.PhBk;

  • replace the PhbkDbContext db-code with the code LpEmpPhBkContext in the phbk-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 generate phbk-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 and LprEmployee02 tables must have a foreign keys, which reference PhbkEmployee-table. In addition LprEmployee02 must have a foreign key, which references PhbkDivision-table... In short, find and replace-approach is optimal.

⚠️ **GitHub.com Fallback** ⚠️