Posts

MS SQL Differences for Dot net Interview

 1. Difference between Primary key and Unique key.        Primary Key              Unique key to create unique identifier. to create uniqueness in a  column. only one primary key  allowed. multiple unique key  allowed. don't allow null value. allow one null value. creates clustered index on a column. creates non clustered index on a  column. 2. Difference between stored procedure and Functions.          Stored Procedure                     Functions We can call function in SP. We can't call SP in Function. Can't call with Select statement. Can call with select statement. we can write DDL and DML commands in SP. We can write only Select statement in SP. Return value is optional. must Return a value. supports try catch.  don't support try catch. supports truncation statements. don't support transaction statements. can have in...

Create First .NET Core Application

Image
In this Blog we will see how to create your first .NET core web app using Visual Studio 2019 First of all, open visual studio 2019 application, In Get started section Select Create a new project.  In create new project window, we see all predefined project templates, from here we select "Asp.net  core Web App template for C# and Click on next.  Next, we will get configure Window where we give project name, Location, Solution name, and keep last box unchecked.  Next, we get Additional information window where we select Target Framework, Authentication Type which we will select none as this point, also keep configure https, Enable docker, Enable Razor Runtime Compilation unchecked at this point. This we get new dot net core web application. We have discussed in brief about project folder in our previous blob please click on link  .NET core folder structure .

C# Interview Questions @2023

Image
  1. What is Datatype conversion ? What are different way of type conversion ?  - Datatype conversion is nothing but converting one data type to another data type for example converting a int value to a float value or vice versa.   - There are 2 different types of Datatype conversion      a) Implicit Conversion – Compiler automatically does a conversion.      b)   Explicit Conversion – When compiler fails for automatic conversion we have to do conversion explicitly.    - Compiler does the conversion automatically in 2 cases      a) When there is no loss of information      b) When there are no chances of runtime exception     - Converting from a smaller datatype to bigger datatype for example int to float in this case there is no loss of information or there is no chance of any exception so compiler will automatically do a conversion which is implicit type conversion. But if ...

How to do Model Validation in Asp.net Core?

Image
Model Validation in .NET core: Model validation is an essential part of any web application that deals with user input. In ASP.NET Core, model validation can be performed by using built-in validation attributes and model binding. Here are the steps to perform model validation in ASP.NET Core: 1.Define validation attributes on model properties:  ASP.NET Core provides  System.ComponentModel.DataAnnotations namespace in which we get several built-in validation attributes that can be used to specify the validation rules for model properties.For example, the [Required] attribute can be used to specify that a property is required, while the [EmailAddress] attribute can be used to validate that a property contains a valid email address. 2.Enable model validation:  To enable model validation in ASP.NET Core, you need to add the [ApiController] attribute to your controller class and call the [FromBody] attribute on the input parameter of the action method. This will automatically ...

.NET Core Features

Image
 Here are 10 key features of .NET Core: Cross-platform support: .NET Core can be used to build applications that run on Windows, macOS, and Linux. High performance: .NET Core is designed to be fast and efficient, with features like just-in-time (JIT) compilation and asynchronous programming. Open-source licensing: .NET Core is available under the MIT license, making it free and open-source. Modular architecture: .NET Core's modular design allows developers to use only the components they need, reducing the size and complexity of applications. Dependency injection: .NET Core includes built-in support for dependency injection, making it easier to manage dependencies and improve code maintainability. Web development: ASP.NET Core, built on top of .NET Core, provides a powerful framework for building modern web applications. Entity Framework Core: .NET Core includes a lightweight version of Entity Framework for database access. Command-line interface (CLI): .NET Core includes a...

.Net core 3.1 Folder structure

Image
In .NET Core 3.1, the default folder structure for a new MVC web application project is as follows: you can see default folder structure in following image - /Controllers: This folder contains the controllers for the application. /Views: This folder contains the views (HTML templates) for the application. /Models : This folder contains the models for the application. /Data: This folder contains the data access layer for the application. /wwwroot: This folder contains the static files (e.g. images, JavaScript, CSS) for the application. /appsettings.json: This file contains the configuration settings for the application. Such as connection  strings, various app secrets /Program.cs : This file contains the entry point for the application i.e. Main method. /Startup.cs: This file contains the startup configuration for the application.it  contains two most important methods i.e. configureService method and configure method You can customize this folder structure to suit your ne...