Implement PetStore application repository
In most applications we have a persistence layer, often called the repository layer. In this
tutorial we create a PetStoreRepo project to use DynamoDB to store our data. Since our
PetStoreRepo will use AWS DynamoDB, we use the LazyStackDynamoDBRepo library
that implements generic Create, Read, Update, Delete and List (CRUDL) operations on the
Amazon DynamoDB. This library is also available as a NuGet package.
3.1 Create the PetStoreRepo project
- Create PetStoreRepo project from "Web and Console → Library → Class Library" template.
- Right Click on Solution PetStore item in the solution explorer. The context menu appears.
- Select the Add → New Project context menu item. The "Choose a template for your new
project" dialog appears.
- Select the "Web and Console → Library → Class Library" project template.
- Click the Next button. The next page in the "Configure your new project" dialog appears.
- Set the Target Framework to ".NET Core 3.1" and press the Next button. The next page appears.
- Enter "PetStoreRepo" as the project name.
- Click the Create button. The project is created with a default class Class1.cs.
- Add Project Dependencies
- Open the PetStoreRepo.csproj file.
- Copy the following ItemGroup into the .csproj file.
<ProjectReference Include="..\..\LazyStack\LazyStackDynamoDBRepo\LazyStackDynamoDBRepo.csproj" />
<ProjectReference Include="..\PetStoreSchema\PetStoreSchema.csproj" />
- Save the file.
- Delete the Class1.cs file from the PetStoreRepo project.
- Right Click on the PetStoreRepo project. The context menu appears.
- Select Add → New Folder. A "New Folder" is created in the project.
- Enter "Models" as the folder name.
- Click on the following class files to download them and then move them into the Models folder.
- Build the project. The project builds successfully.
Note the reference to the LazyStackDynamoDBRepo.csproj residing in the LazyStack repository
we cloned in the first step of this tutorial. In a production app you might choose to reference
the corresponding NuGet package instead.
In this step we created the PetStoreRepo project by:
- Creating a PetStoreRepo project using the Class Library template.
- Adding classes for Categories, Orders, Pets and Tags.
- Referencing the LazyStackDynamoDBRepo project.