Why(s) and How(s) of ASP.NET MVC: Part 2

ASP.NET MVC and Web Forms actually have a lot in common.

Concerns ASP.NET MVC Web Form
Security Forms/Windows Authentication, MemberShip Forms/Windows Authentication, MemberShip
Validation Data Annotations Server Controls for validation
State Management Session and profile state View State/Cookies/Query Strings
Cross Page Data Transfer controller to view/controller to request ViewData, ViewBag, and TempData Session/Query String
Health monitoring Health monitoring Health monitoring
Caching output and data caching output and data caching
Master Page Layout Page Master Page
UserControl Partial View UserControl
RAD Control HTML helper Server Controls
Syntax Razor View Engines ASPX View Engines



By Sriramjithendra Posted in ASP.NET

ORM and EntityFramework – intro

ORM (Object Relational Mapping) is basically an approach for storing data from domain/entity objects to relational database in an automated way without writing much code. A true ORM is independent of what database server we refer to, the code underlying ORM’s is database independent and can run with any database server having similar database with a structure needed by the application. ORM has 3 main parts: Entity class objects, Relational DB objects and information on how domain objects maps to relational DB objects, i.e., tables, views and storedprocedures. Continue reading

Deferred (or) Lazy execution Vs Immediate execution in LINQ

Deferred/Lazy execution: This type of a statement is executed only when the output is a necessity to proceed further in the program; until then, the execution can wait! This is the standard way in which most Language Integrated Queries (LINQ) are executed.
Deferred Execution is extremely helpful in scenarios where you don’t need the entire output to be computed at a point of time. This is made possible through the use of interation over an IEnumerable having a yield functionality.  Continue reading

HR Interview Questions and Answers

Q – How would you best describe yourself ?

A – While this exactly isn’t a question; however, answering this in the wrong way can hurt your chances greatly of getting any job. This actually can be a tricky question. Hiring managers cannot ask certain questions legally; however, if you go away on a tangent while answering, you might tell them a few things about you which are better left unstated.” The worst means to approach this is to tell about your life story to them, which is something which they definitely aren’t interested in. The most excellent method to approach this request is to just discuss what all your interests are related to that job and how your background actually makes you the right candidate. Continue reading

How to prevent inserting empty string in SQL Server?

Setting a field not null doesn’t mean this field doesn’t accept blank strings too! so for preventing empty strings, beside not null definition just add a check constrain to check the empty ones.

create table t(n varchar(64) not null ,constraint chkn check (ltrim(n)!=”));
insert t values('Danial (this is okay!)'),
		('   Pedram (this is okay too!)'),
		('        Code Project folks(this is still okay!)!      '),
		('    '/*Not okay!*/),(null /*Not okay!*/ );

simple remove the spaces with ltrim() function, and check the value should not be as a empty string ”.

Running dynamic query in SQL Server. Exec() and sp_executesql

Both exec() and sp_executesql are used for running dynamic SQL commands, just need to prepare the commands as a String object and call the sp_executesql.
Both of exec() and sp_executesql are same, exec() is the new face of sp_executesql has added in SQL Server V9.

declare @com nvarchar(1024);
set @com='create table MyTable'+convert(varchar(3),@i)+'(id int,[name] varchar(64));';

exec sp_executesql @com;

--exec(@com);--as same as above, the new face