UNIT-5

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

ADO.

NET

UNIT 5
INTRODUCTION
• What is data ?
• What is Database?
• What is Relational database?
• What is RDBMS?
• What is SQL?
INTRODUCTION
 What is ADO.NET ?
• Its is a part of .Net framework technology that allows
us to access and modify data from different data
source.
• It support many types of data source such as Oracle ,
SQL server…etc
• The .Net framework provides a number of data
provider that we can use.
• ADO.NET provide a bridge between the front end
and the backend database.
ASP.NET Data Source Controls

Name Description
SqlDataSource Connects data-binding controls to
SQL databases
AccessDataSource Connects data-binding controls to
Access databases
XmlDataSource Connects data-binding controls to
XML data
ObjectDataSource Connects data-binding controls to
data components
SiteMapDataSource Connects site navigation controls to
site map data
What is ADO.NET ?

• A rich set of classes, interfaces, structures and


enumerated types that manage data access from
different types of data stores
• Features
– A robust disconnected model.
– Integrate XML support.
– Data from varied Data Sources
– Familiarity to ADO programming model.
– Enhanced performance
Managed Provider

Your Application

ADO.NET Managed Provider

OLE DB
Provider
SQL Server
Database Database

SQL Managed Provider ADO Managed Provider


ADO.NET architecture
 Microsoft introduced ADO a data access technology for
connecting to the database in 1996.

 ADO is an object oriented database access technology that


supports both connected and disconnected mode of
operation.

 You can use ADO.NET to perform CRUD


(Create,Read,Update,Delete) operation in your application.

 It also provides support for XML data access and it has a rich
object model.
ADO.NET architecture
Connected Model Disconnected Model
.Net Application .Net Application

Open Connection

Open connection Retrieve data at client side

Run Commands Close connection

Manipulate data
Retrieve Results
Open connection
Close connection
Update tables

Close connection
Order
Payroll Processing
database database
ADO.NET architecture
 Component
 DataSource component
Data Access - LINQ
What is LINQ?
 Language Integrated Query (LINQ, pronounced
"link").
 LINQ is a uniform programming model for
querying and manipulating data with a
consistent model from any data source.
 LINQ is just another tool for embedding SQL
queries into code.
 Extends powerful query capabilities to C#,
VB.NET languages.
LINQ Architecture
C# VB Others…

.Net Language Integrated Query (LINQ)

LINQ enabled data sources


LINQ enabled ADO.NET

LINQ LINQ LINQ LINQ LINQ


To Objects To Datasets To SQL To Entities To XML

<book>
<title/>
<author/>
<price/>
</book>

Objects
XML
Relational
LINQ Features
• Language Integration
• Single general purpose Declarative Programming
• Standard Query Operators that allow
• traversal, filter, and projection operations
• Transparency Across Different Type Systems
• Query expressions benefit from
– rich metadata
– compile-time syntax checking
– static typing
– IntelliSense
The Syntax
from id in source
join id in source on expr equals expr
let id = expr
where condition
orderby ordering, ordering, … }
select expr | group expr by key

var contacts = Query


from c in customers expressions
where c.City == "Hove"
select new { c.Name, c.Phone };
Lambda
var contacts = expressions
customers
.Where(c => c.City == "Hove")
.Select(c => new { c.Name, c.Phone });

Extension
methods
Query Operators
Project Select <expr>
Filter Where <expr>, Distinct
Test Any(<expr>), All(<expr>)
Join <expr> Join <expr> On <expr> Equals <expr>
Group Group By <expr>, <expr> Into <expr>,
<expr>
Group Join <decl> On <expr> Equals <expr>
Into <expr>
Aggregate Count(<expr>), Sum(<expr>), Min(<expr>),
Max(<expr>), Avg(<expr>)
Partition Skip [ While ] <expr>, Take [ While ]
<expr>
Set Union, Intersect, Except
Order Order By <expr>, <expr> [ Ascending |
Descending ]
LINQ to Objects
• It is the use of LINQ queries with any IEnumerable or
• IEnumerable(T) collection directly, without the use of an
intermediate
• LINQ provider or API such as LINQ to SQL or LINQ to XML.
• It allows query any enumerable collections such as
– List(T),
– Array, or
– Dictionary(TKey, TValue).
• The collection may be user-defined or may be returned by a .NET
Framework API.
LINQ to Objects

public void TestLinqTOObjects( )


{ string[] tools ={ "Tablesaw“,"Bandsaw",
Planer“,"Jointer", "Drill", "Sander" };
var list = from t in tools
select t;
DropDownList1.DataSource =list;
Page.DataBind();
}
LINQ to SQL
• Used for managing relational data as objects.
• Maps the relational data model to an object
model in .NET language.
• Translates into SQL the language-integrated
queries and sends them to the database for
execution.
• LINQ to SQL translates the results back to
objects that you can work with in your own
programming language.
LINQ to SQL
Accessing relational data with LINQ
[Table(Name="Customers")]
public class Customer
{
public string CustomerID;
public string City;
}

// DataContext takes a connection string


DataContext db = new DataContext("c:\\northwind\\
northwnd.mdf");

// Get a typed table to run queries


Table<Customer> Customers = db.GetTable<Customer>();

// Query for customers from London


var q = from c in Customers
where c.City == "London"
select c;
LINQ to SQL
Allow developers to access database as
object in c#.

By using LINQ we are able to use LINQ


query operators and methods instead of
learning SQL.
LINQ TO XML - XLINQ
• API to work with XML in .NET with the power of LINQ.
• XLINQ Features :
– It provides an in-memory XML programming interface that leverages
– The .NET Language-Integrated Query (LINQ) Framework.
– It provides functionality to read, write, and manipulate XML
documents.
– XLinq lets you run SQL like queries on XML documents.
– It works as cleaner, simpler, smaller and faster XML API

You might also like