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.
The result will be the list of SQL Server stored procedure names that refers to particular table or column.
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
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
[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:
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:
- Dissociate()
- ExternalLogin()
- ExternalLoginCallback()
- LinkLogin()
- LinkLoginCallback()
- ExternalLoginConfirmation()
- ExternalLoginFailure()
- RemoveAccountList()
- The member constant XsrfKey
- The entire class ChallengeResult
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:
Popular Tutorials
- Creating Cookie in ASP.NET MVC Action | Handling Cookies in ASP.NET MVC | Set Cookie Expiry in ASP.NET MVC | ASP.NET MVC Tutorial
- Generating Multiline TextBox or TextArea with @Html.EditorFor in ASP.NET MVC
- Generating Unique Token in C# | Generating Unique Token that Expires after 24 Hours in C# | C# Tutorial
- Drag & Drop File Upload In ASP.NET MVC Using dropzone js with Fallback Browser Support | ASP.NET MVC Tutorial
- Loading PartialView Via JQuery In ASP.NET MVC | Returning PartialView From ASP.NET MVC Action | ASP.NET MVC Tutorial
- How To Enable Role Manager Feature In ASP.NET MVC? | ASP.NET MVC Interview Question
- How To Add CSS Class And Custom Property in Html.TextBoxFor? | ASP.NET MVC | RAZOR
- Send and Receive SMS and MMS Messages Using Android 4.4 SMS API | Android Video Tutorial
- How to Get Browser Agent from ASP.NET Web API Controller? | ASP.NET Web API Tutorial
- How to Override the Common Route Prefix? | ASP.Net MVC Interview Question