Microsoft Azure Components Infographics | Microsoft Azure Tutorial

Azure components

Finding all Stored Procedures that calls a Function in SQL Server | SQL Server Tutorial

The below Stored Procedure searches within all the stored procedures in the SQL server database, views, and functions for the given function name. This stored procedure also search for any text written in the stored procedure, not just function names.

CREATE PROCEDURE dbo.Find_Text
    @SearchValue nvarchar(500)
AS

SELECT DISTINCT
    s.name+'.'+o.name AS Object_Name,o.type_desc
    FROM sys.sql_modules        m
        INNER JOIN sys.objects  o ON m.object_id=o.object_id
        INNER JOIN sys.schemas  s ON o.schema_id=s.schema_id
    WHERE m.definition Like '%'+@SearchValue+'%'
        --AND o.Type='P'  --<uncomment if you only want to search procedures
    ORDER BY 1
GO

Finding Stored Procedures that Accesses Particular Table or Column in SQL Server | SQL Server Tutorial

By querying the Procedures table in Sys as given below, we can find the SQL Server stored procedures that refers particular column are tables.

SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%TableNameOrColumnName%'

The result will be the list of SQL Server stored procedure names that refers to particular table or column.

Deleting Multiple Records in Entity Framework | Entity Framework Tutorial

Sometimes you may need to delete multiple records. In such case, developers use to iterate through the collection using foreach and will set each entity state to modified. Some developers use to write an extension method as below to handle deleting multiple records in entity framework.

Extension Method:

public static void DeleteObjects(this ObjectSet set, Expression> predicate) where T : EntityObject { foreach (var entity in set.AsQueryable().Where(predicate)) set.DeleteObject(entity); }

Usage of Extension Method

db.Employees.DeleteObjects(x => x.Country == "India");

However to make the life of the .Net developer easier, entity framework 6 has introduced a method named RemoveRange to delete multiple records at one shot as given in the below code snippet:

db.People.RemoveRange(db.Employees.Where(x => Country == "India"));

How to Get Browser Agent from ASP.NET Web API Controller? | ASP.NET Web API Tutorial

The easiest way to get the full user-agent from inside an ASP.NET Web API-controller is as given below:
var userAgent = Request.Headers.UserAgent.ToString();
It gives exactly the same result as doing the manual step like this:
// var headers = request.Headers.GetValues("User-Agent");
// var userAgent = string.Join(" ", headers);

Excluding Required Property from ModelState.IsValid | ASP.NET MVC Tutorial

You can exclude any property from validating using parameter binding. Set the exclude property in Bind attribute of a parameter as [Bind(Exclude = "Password")] 

In this way, by add exclusions to your action and explicitly state what can and can't be binded we can achieve in ASP.NET MVC

public class Person 
{ 
    public int id { get; set; } 

    [Required] 
    public string FirstName { get; set; } 

    [Required] 
    public string LastName { get; set; } 
} 
FirstName And LastName are Requerd. I want to exclude LastName from validating:

public ActionResult Edit([Bind(Exclude = "LastName")]Person person)
{
    //your code for ModalState validation;    
}

Process Flow of Single and Multitenancy ASP.NET MVC Application | ASP.NET MVC Tutorial

Single-Tenancy Application
The steps that lead from a user entering a website address in his browser to viewing the content are fairly straightforward. The browser sends a request for the content at that address to a server. The server receives the request, matches the address with an application, and passes the request on to that application for processing. The application reads the request, creates a response, and passes the response back to the server. The server returns the response to the browser and the browser presents the response content to the user. This is sometimes referred to as a single tenant application architecture. Each client application is matched with a single IP address and host name so that, as requests come in, the server can route them to the appropriate application (Figure 1).

Simplifying AccountController by Removing External Login Related Actions | ASP.NET MVC Tutorial

There are a number of methods on AccountController related to External Logins. If you examine AccountController carefully, you can go through and delete the code for the following actions:
  • Dissociate()
  • ExternalLogin()
  • ExternalLoginCallback()
  • LinkLogin()
  • LinkLoginCallback()
  • ExternalLoginConfirmation()
  • ExternalLoginFailure()
  • RemoveAccountList()
Additionally, there is a code #region for helpers. From here, we can delete the following items:
  • The member constant XsrfKey
  • The entire class ChallengeResult
At this point, we can also right-click in the code file and select Remove and Sort Usings to clear out unused namespaces

Delete External Login Related Views:
Along with the unnecessary Controller methods we just removed, we can also remove the unnecessary views related to external logins. If we open the Views => Account folder in Solution Explorer, we find we can delete the highlighted views below from our project: