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 NuGet package
that implements generic Create, Read, Update, Delete and List (CRUDL) operations on the
3.1 Create the PetStoreRepo project
- Create PetStoreRepo project from "Class Library (C#)" template.
- Right Click on Solution PetStore item in the solution explorer. The context menu appears.
- Select the Add → New Project context menu item. The "Add a new project" dialog appears.
- Find the "Class Library (.NET Core)" project template.
- Double click on the "Class Library (.NET Core) C# template. The Configure your new project window is
presented. Note: You have to look at the icon to see which template is for C#.
- Enter "PetStoreRepo" as the project name.
- Click on the Next button. The 'Additional Information' page is presented.
- For the 'Target Framework', select '.NET Core 3.1 (Long-term support) option.
- 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 C# Class(.NET Core) Library template.
- Adding classes for Categories, Orders, Pets and Tags.
- Referencing the LazyStackDynamoDBRepo project.