Posts

Showing posts from June, 2021

SQL Index and SQL Plan

Image
Index : Indexes are used to improve the performance of searching. An index makes a search faster by using a Balanced Tree (B-Tree) Structure.  In B-Tree Structure data divided into root node, non- leaf nodes and leaf nodes. An index is a pointer to data in a table. Indexes are special lookup tables that the database search engine can use to speed up data retrieval. Example : Index has two types which helps to search fast : 1. Clustered Index : A Clustered Index stores the actual data at the leaf node. In SQL server clustered index is created automatically, when a primary key is created. Only one clustered index is created per table. Creating Clustered Index in SQL server :   1.  Go to Design of a table, then right click on column and select Indexes/ Keys : 2.  After that in Table Designer set 'Create As Clustered' as Yes, See Clustered index is created : 2. Non-Clustered Index: The leaf nodes of non-clustered index doesn't know where the data is? Leaf node of non-clu...

ASP.NET MVC Interview Questions : Part-4

Image
  Q.1  What is dependency injection? The DI provides the objects that they needs(dependencies). DI is a design pattern used to implement IoC(Inversion of Control - Here control of object is transferred to the framework). It allows the creation of object outside the class and provides those object to class. Using DI we move creation and binding outside the class. DI pattern has 3 classes : Client class(dependent class : Depends on service class), Service class(dependency : Provide service to client) and Injector class(Injects service class object to client class). Q.2 How can we configure data from appsettings.json? We can configure using two ways :           1) Using IConfiguration :  It is available in DI container and directly access JSON properties by injecting IConfiguration in constructor of controller or class.  We can define readonly property of type IConfiguration.          2) Using options pattern :  To ...

ASP.NET MVC Interview Questions : Part 3

Image
  Q.1  How to pass model to the view? We can pass model first to controller action method then controller pass it to view.  We can pass this using ViewData, ViewBag, TempData, strongly typed model object. When we pass data to view using ViewBag, ViewData, TempData then that view becomes loosely-coupled. We can better understand by given example below: Q.2  What is strongly typed views and how do we create them? The view which bind with any model is called as Strongly-typed view. Strongly Typed views provides compile-time error checking as well as intelligence.  If we misspell the property or method name, then it will known at compile time rather than at run-time.  We need to pass model object as a parameter to view() method.  Eg. protected internal ViewResult View(object model) - This is the overloaded version of View() method which we can use to pass data from controller to view. Q.3  How we can change the startup controller name and action name...

SQL backup , restore and scripts

Image
  SQL  Backup : The backup copies the data or log records from database to device such as disc. This copy can be used to restore or recover the data after failure. Their are three main types of backup : Full backup : It is a backup of database which represent the whole database at the time the backup finished. It contains all the data in a specific database or set of filegroups.  Differential backup : It is the backup based on latest full backup of complete or partial database. Log backup : It is the backup of transaction logs that have all log records that are not backed up in previous log backup. Steps for back up database : 1) Connect to database and expand database, select the database which we want to backup : 2) Select the backup type: 3) You can add new destination and add .bak extension : 4) Click on "Ok" and the database backup completed : 5) You can check whether the backup is created successfully or not by going to destination folder : SQL  Restore : The r...