Skip to main content

Posts

Introduction On OData(Version 8) In .Net5 Web API Application

In this article, we are going to understand the steps to integrate OData(Version 8.0) into our .Net5 application. OData: The OData(Open Data Protocol) is an application-level protocol for interacting with data via a RESTful interface. OData supports the description of data models, editing, and querying of data according to those models. OData's main advantage is users can query the API results. So OData query or filter can be done in two different approaches: Approach - 1: A response collection from an action method can be filtered by the OData. Means if action method fetched the collection of records from the database and returning to user, in the middle OData will filter the response data based on user query. Approach - 2: Action method that returns an entity framework query of type 'IQueryable', then OData generates a SQL query based on the user OData query request, then executes against the database and then returns the result to the users. OData query features are: $se

.NET5 Web API Display PDF In Browser

In this article, we will display the PDF on the browser as a response to the .Net5 Web API endpoint. Create A .Net5 Web API Sample Application: Now let's create a .Net5 Web API sample application to begin our coding. API Endpoint To Load PDF From Physical Path: Now we are going to create a web API endpoint that will read the PDF file from the server physical folder. So first let's add a sample pdf file in our API server, so create 'wwwroot' folder(framework understandable folder to store the static files). Now add the 'pdf' folder inside of the 'wwwroot' folder and then add our sample pdf file as below. Create a new controller like 'PdfController.cs' inside of the 'Controllers' folder. Controllers/PdfController.cs: using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; namespace Dot5.PDF.OnBrowser.Controllers { [ApiController] [Route("[controller]")] public cl

.Net5 Blazor WebAssembly Application Invoke GraphQL Endpoints Using Strawberry Shake Library

In this article, we will implement a Blazor WebAssembly Application that consumes GraphQL endpoints using the Strawberry Shake library. Strawberry Shake: Strawberry Shake is a GraphQL client library that can be used by the .Net Standard Library. So all .NetCore applications (from .Net5) like APIs, MVC, Blazor Server, Blazor WebAssembly, etc. Strawberry Shake will generate all boilerplate code for the GraphQL Server schema, which lays an easy path for consuming the data from our Blazor WebAssembly application. Strawberry Shake CLI Tool Configuration: Strawberry Shake CLI needs to be configured because CLI will help us to generate the GraphQL client. Create a dotnet tool-manifest dotnet new tool-manifest Now install the Strawberry Shake CLI Tool dotnet tool install StrawberryShake.Tools --local Create A .Net5 Blazor WebAssembly Project: Let's start our journey by creating a .Net5 Blazor WebAssembly application sample project. Visual Studio users can easily create .Net5 Bl

.NET5 Blazor Server CRUD Operation Using Entity Framework Core

In this article, we are going to implement CRUD operations in .Net5 Blazor Server application. Blazor Server: Blazor Server is a single-page application. At the server, a pre-rendered HTML output of the page will be delivered to the user browsers. Any UI update, event handling, javascript calls will carry over by a SignalR connection to the server. So application updates or depends on the continuous connection of the SignalR. So Blazor Server is a single-page application that will be made of c#. Since the blazor server only outputs the pre-rendered HTML to the client, so there is no c# code downloading into user browsers like in Blazor Webassembly(c# code downloaded and runs in browser for blazor webassembly application). Role Of SignalR Connection: A Blazor Server application works over a SignalR connection. A Blazor Server application creates a UI State memory at the server which will be interacted by the SignalR connections. If a SignalR connection got interrupted, then the clie