Skip to main content

Posts

Showing posts with the label Dotnet Core

Hot Chocolate GraphQL Pagination Using UseOffsetPaging Middleware[.NET6]

In this article, we are going to understand the GraphQL pagination using the 'UseOffsetPaging' middleware. UseOffsetPaging Middleware: Hot chocolate provides default pagination middleware that is 'UseOffsetPaging'. Simply applying 'UseOffsetPaging' on the resolver method will enable the pagination. This middleware implicitly reads the variables like 'skip' and 'take' from the request query and then generates the raw SQL query from the IQueriable. Create A .NET6 Web API Project: Let's create a .Net6 Web API sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any .NET6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. .NET CLI Command: dotnet new webapi -o Your_Project_Name Sample Table Data: Let's have a sample Todo table as shown. Setup EntityFramework Core Database Context: Let's

Part-5 Ocelot API Gateway For Microservices[.NET6 Microservice Series]

In this article, we are going to implement API Gateway for our microservices to define a unified URL with that all client applications can consume it instead of consuming individual URLs of the microservices. Part-4 Asynchronous Data Communication Between Microservices Using RabbitMQ Message Broker With MassTransit[.NET6 Microservice Series] Need Of API GateWay?: Consider our microservice where we have two microservice applications. The 'Manufacture.API' application runs at 'https://localhost:7132' and The 'SalesBusiness.API' runs at 'https://localhost:7456' so from this we can understand we have 2 different domains bound to our each microservices. So in the real-world application, we may deal with 10plus microservices base on our business. So handling or managing or consuming 10plus different domains by a client application is very hard. So to solve this problem API Gateway comes into the picture. So API Gateway is also a simple API project with its

Part-3 Create A Microservice For The Orders Endpoint[.NET6 Microservice Series]

In this article, we will create our second microservice application that contains the orders endpoint. The microservice application consists of simple or single module logic endpoints. So here I'm going to create 2 endpoints like HTTP GET, HTTP POST for the 'Orders' to accomplish our demo. Part-2 Create A Microservice For The Products Endpoint[.NET6 Microservice Series] Create A .NET6 Web API Application: Let's create our second microservice application with .NET6 Web API application. Let's name our microservice project 'SalesBusiness.Api'. To create .NET6 application recommended IDE's are 'Visual Studio 2022', 'Visual Studio Code'. In this demo, I'm using .NET CLI and Visual Studio Code editor. CLI command dotnet new webapi -o Your_Project_Name Install NuGet Packages: Install EntityFramework Core NuGet. .NET CLI command dotnet add package Microsoft.EntityFrameworkCore --version 6.0.3 Package Manager command Install-Packa

Part-2 Create A Microservice For The Products Endpoint[.NET6 Microservice Series]

In this article, we will create a microservice application that contains the product endpoint. So creating a microservice means the application contains endpoints related to a specific module or component. So here I'm going to create 2 endpoints like HTTP GET, HTTP Post for the products to accomplish our demo. (We can implement the entire CRUD operation endpoint if we want). Click here for Part-1 of the .NET6 Microservice Series . Create A .NET6 Web API Application: Let's create our first microservice application with .NET6 Web API application. Let's name our microservice project as 'Manufacture.Api'. To create .NET6 application recommended IDE's are Visual Studio 2022', 'Visual Studio Code'. In this demo, I'm using .NET CLI and Visual Studio Code editor. CLI command dotnet new webapi -o Your_Project_Name Install NuGet Packages: Install EntityFramework Core NuGet. .NET CLI command dotnet add package Microsoft.EntityFrameworkCore --ve

Part -1 Introduction On Microservice And SQL Database Design For Microservices [.NET 6 MicorService Series]

In the .NET6 Microservice series, this is the first installment article, where we are going to understand about the Microservices and also we are going to create SQL databases for our sample microservices of this series. Monolithic Architecture: Monolithic architecture is traditional or most commonly used for developing the application. In this approach, all the business units or logic are implemented under a single application. A single database can be used for data serving. Microservice Architecture: In Microservice architecture each business unit or logic is developed as separate small individual applications. So each separate application is lightweight and they have their own responsibilities to carry on and these individual services are called Microservices. In Microservices each service has its own code and databases so anyone service down remaining microservice services are unaffected. Each microservice can be hosted anywhere on the web. Each microservice can interact wi

Unit Testing Asp.NetCore Web API Using xUnit[.NET6]

In this article, we are going to write test cases to an Asp.NetCore Web API(.NET6) application using the xUnit. xUnit For .NET: The xUnit for .Net is a free, open-source, community-focused unit testing tool for .NET applications. By default .Net also provides a xUnit project template to implement test cases. Unit test cases build upon the 'AAA' formula that means 'Arrange', 'Act' and 'Assert' Arrange - Declaring variables, objects, instantiating mocks, etc. Act - Calling or invoking the method that needs to be tested. Assert - The assert ensures that code behaves as expected means yielding expected output. Create An API And Unit Test Projects: Let's create a .Net6 Web API and xUnit sample applications to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any.Net6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. Create a fo