Skip to main content

Posts

Showing posts with the label API

A Demo On .Net5 Web API Pagination Using Dapper ORM

In this article, we are going to implement a sample demo on pagination in .Net5 Web API application using Dapper ORM for database communication. Create A Sample Table: To accomplish our demo let's create a sample table. CREATE TABLE [dbo].[Todo]( [Id] [int] IDENTITY(1,1) NOT NULL, [ItemName] [varchar](max) NULL, [IsCompleted] [bit] NOT NULL CONSTRAINT Pk_Todo PRIMARY KEY (Id) ) Create A .Net5 Web API Application: Let's create a .Net5 Web API application to implement our pagination. Specify the project name and solution name Select target framework a .Net5 Create Table Model and Pagination Response Model: Now we need to create to models like 'Todo'(Table Class) and 'PagingResponseModel'(Class that  used as API response model which contains all pagination properties). So let's add a new folder like 'Models' and our 2 classes inside of it. Models/Todo.cs: namespace Dot5.API.Dapper.Pagging.Models { public class Todo { public

.Net5 Web API Redis Cache Using StackExchange.Redis.Extensions.AspNetCore Library

In this article, we are going to explore the integration of Redis cache in .Net5 Web API application using the 'StackExchange.Redis.Exntensions' library. Note:- Microsoft has introduced an 'IDistributedCache' interface in dotnet core which supports different cache stores like In-Memory, Redis, NCache, etc. It is simple and easy to work with  'IDistributedCache', for the Redis store with limited features but if we want more features of the Redis store we can choose to use 'StackExchange.Redis.Extensions'.  Click here for Redis Cache Integration Using IDistributedCache Interface . Overview On StackExchange.Redis.Extnesions Library: The 'StackExchange.Redis.Extension' library extended from the main library 'StackExchange.Redis'. Some of the key features of this library like: Default serialization and deserialization. Easy to save and fetch complex objects. Search key. Multiple Database Access Setup Redis Docker Instance: For this sampl