23 Create ModelViews (Edition) (Wpf, Xamarin) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki

  • View (or ModelView) is the structure that the Web Api service sends to and receives from the client. For each entity, the developer must create at least one view.

  • To Add a View to the project

    • Run Visual Studio and Open “WpfDemo” solution
    • Right Click “Literature” of the “Dm03Views”-project and select “ModelView Wizard” menu item to open the Wizard dialog
  • Note:

    • 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.

picture

- Click “Next”-button
  • On the second page of the dialog the developer should select existing DbContext file.
    • Select:
      • Dm02Context (project)
      • LitDbContext (context)

picture

- Click “Next”-button
  • On the third page of the dialog the developer should select entity file.
    • Select:
      • Dm01Entity
      • LitEdition

picture

- Click “Next”-button
  • On the fourth page of the dialog the developer can select existing view for modification.
    • Uncheck “Select View”

picture

- Click “Next”-button
  • On the fifth page select root node and check “Generate JsonProperty Attribute”.
    • Two classes will be generated:
    • “View” and “Page View”.
    • The last one is used by pagination.

picture

- Leave these names unchanged. 
  • On the fifth page check “Is Selected” for “EditionId” and “EditionName” nodes. Leave “Property Name” and “Json Property Name” unchanged.

picture

- Click “Next”
  • On the sixth page select “ViewModel.cs.t4”

picture

- click Next
  • On the seventh page click “Save”.
    • Open “C:\Development\Demo\ReactDmLit” which is a root of the solution.

picture

- New “.json” file has been created. This is the repository of the wizards.

picture

- Click “Next”
  • On the eighth page select “ViewModelPage.cs.t4” and click Next.

picture

- It generates the second class
  • On the ninth page click save and close the dialog. The repository (.json) file has been updated again.

picture

- Note #1:
    - The repo file is updated only when you click the save button.
- Note #2:
    - A separate repo file is created for each DBContext.