abdullahkhanjmm / dotnet-roadmap-2024

0 stars 0 forks source link

Implement GraphQL API for Employee CRUD Using Dapper with DB First Approach in ASP.NET Core (.NET 8.0) #17

Open abdullahkhanjmm opened 1 month ago

abdullahkhanjmm commented 1 month ago

Task: Implement GraphQL API for Employee CRUD Using Dapper with DB First Approach in ASP.NET Core (.NET 8.0)

Objective

To create a GraphQL API that allows for CRUD (Create, Read, Update, Delete) operations on an Employee entity using the Dapper ORM in a DB First approach. The goal is to efficiently interact with the database using GraphQL for these operations.

Requirements

  1. Environment Setup:

    • Ensure you are working in an ASP.NET Core (.NET 8.0) project.
    • Install the following NuGet packages:
      • Dapper
      • GraphQL
      • GraphQL.Server.Transports.AspNetCore
      • GraphQL.SystemTextJson
      • Microsoft.Extensions.DependencyInjection
  2. Database First Approach:

    • Reverse engineer the existing database to generate the necessary entity classes. Use Dapper for ORM, ensuring that you do not rely on Entity Framework.
    • Set up a connection to the database using a connection string stored in the appsettings.json file.
  3. Employee Entity:

    • Create a class to represent the Employee entity. Here is a sample class:
public class Employee
{
    public int EmployeeId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public string PhoneNumber { get; set; }
    public DateTime HireDate { get; set; }
    public string JobTitle { get; set; }
    public decimal Salary { get; set; }
}
  1. GraphQL API Implementation:
    • Define the GraphQL schema including queries and mutations for Employee CRUD operations.
    • Use Dapper to interact with the database. Ensure that the operations handle common cases like filtering, pagination, and sorting.

JMMAwais commented 1 month ago

https://github.com/JMMAwais/DapperImplementationWithGraphqlAPI

asifaliwork commented 1 month ago

https://github.com/asifaliwork/Dapper