Skip to main content

Posts

Showing posts from October, 2014

What is Entity Framework and ORM tools

According to Microsoft: The Microsoft ADO.NET Entity Framework is an Object Relational Mapping that enables to .NET developers to work with relational data as domain-specific objects, eliminating the need for most of the data access plumbing code that developers usually need to write. Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects. The Entity Framework's ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals. Simply you may say: Entity framework is an Object Relational Mapping tool. It does provide an automated mechanism for accessing & storing the data in the database, and for working with the results, in addition to DataReader and DataSet.
What is ORM and its need
ORM is a tool for storing data from domain objects to a relational…

select in SQL Server

Select  keword use to fetch data from database table.
Select query is given below
Select * from tbl
To select top 10 records the query is given bellow
Select top 10 *from tbl
Note: Top keyword use to fetch top 10 records from database table.

CHECK constraint in sql server

CHECK-The CHECK responsible for enables a condition to check the value being entered into a record
Example- In the following example, we create a PRODUCT table it has a PRICE column and its value should be greater than 20.00, so that you cannot have anyproduct which price is less than or equal to 20.00
CREATETABLEPRODUCT ( IDINTNOTNULLIDENTITY(1,1), SKUVARCHAR(20)NOTNULL, TITLEVARCHAR(200)NOTNULL, PRICEMONEYNOTNULLCHECK(PRICE>20.00), DESCRIPTIONVARCHAR(2000)NULL,

FOREIGN KEY constraint in sql server

FOREIGN KEY-This constraints responsible touniquely identified a rows or records to another table.
Example-
Following table structure can clear your concept of foreign key constraint.
Product Table
CREATETABLEPRODUCT ( IDINTNOTNULLIDENTITY(1,1), SKUVARCHAR(20)NOTNULL, TITLEVARCHAR(200)NOTNULL, PRICEMONEYNOTNULL, DISCRIPTIONVARCHAR(2000)NULL,

PRIMARY KEY constraint in sql server

PRIMARY KEY-Primary key constraint is a combination of a NOT NULL constraint and a UNIQUE constraint. This constraint ensures that the specific column for a table has a unique identity.
Example- Following we create a table PRODUCT in which column ID has primary key constraints.
CREATETABLEPRODUCT ( IDINTNOTNULLIDENTITY(1,1), SKUVARCHAR(20)NOTNULL, TITLEVARCHAR(200)NOTNULL, PRICEMONEYNOTNULL, DESCRIPTIONVARCHAR(2000)NULL, DTCREATEDATETIMENULL