C Charp (C#) ADO.NET | Data Set | Data View | Data Table
Disconnected Environment:
In ADO.NET, a disconnected environment is one in which an application is not directly connected to a data
source.
In this
environment, data stored in DataSet and manipulated are
performed.
DataSet:
A DataSet
is a memory based relational representation of data. It is a part of
disconnected environment.
A DataSet
is a disconnected, cached set of records that are retrieved from a database.
The data set acts
like a virtual database containing tables, rows and columns.
There are two types
of data sets: Typed DataSet and Untyped DataSet.
Typed Data set:
A typed DataSet
is derived from DataSet classes and has associated XML schemas which is created
at the time of creation of the database.
The XML schemas
contains information about the DataSet structure such as tables,
columns and rows.
Data is transferred
from a database into a DataSet and from the DataSet
to another component in the XML format.
A typed DataSet
structure is stored in an XML format. The DataSet is saved as an XSD file.
The structure of a
typed DataSet is decided at the time of its creation.
When a typed DataSet
is created, the data commands are generated automatically by using the columns
names from the data source.
Tables and their
columns can be accessed by using names while programming.
A typed DataSet
class contains a public nested class to represent each data table in the DataSet.
A typed DataTable
class contains data columns fields. These fields represent the different
columns in the data fields.
The DataTable
class provides properties which allows you to access these data columns objects
directly.
A typed DataSet
class contains nested class to represents rows in its data tables.
Untyped Data set:
An untyped DataSet
does not have any associated XML schemas. In an untyped DataSet the tables and
columns are represented as collection.
The structure of an
untyped DataSet is now known during compilation or the data being used
not have a f\default structure.
DataSet Object Model:
A DataSet
contains a collection of data table and data relation objects. Each data table
object contains a collection of rows for representing the data.
A DataRelation
object specifies the relationship between the rows for navigation purpose.
A DataTable
object also contains unique and foreign key consisting to enforce data
integrity.
A DataSet
is created with the help of DataSet object. A DataSet
object provides an in memory cache of data.
The DataSet
class is defined in system data namespace.
The DataSet
objects contains a collection of data table objects, each containing one or
more tables.
A DataTable
object contains one or more columns each represented by a data columns object.
To add a column to
a data table, create data column object and call Add() method on column
collection.
The column collection
enables you to access the columns in a data table.
A DataTable
object also has rows collection that allows rows to be accessed in a data set.
A DataTable
object contains one or more rows each represented by a data row object.
The Data
row has methods : Add(), InsertAt(), Find(), Select(),
Remove(),
RemoveAt(),
Delete().
We can create data
relation object for creating the relationship between multiple tables by using
primary key and foreign key constraints.
The tables that has
a primary key constraints is known as the parent table and the table that has a
foreign key constraints is known as child table.
Parent table shows
one side relationship and child table shows the many side relationship in a DataSet.
A data set relation
property gets the collection of relation that link table and allow navigation
from parent tables to child tables.
DataView:
A DataView
is a part of the disconnected environment. The System.Data namespace
defines the DataView class that enables you to create various views of the
data stored in a data table.
A DataView
can be used to sort or to filter data in a data table. It can also be used to
add, modify, and delete rows in a data table.
A DataView
provides a dynamic view of data stored in DataTable. If any data is modified
in data table, the data view associated with the data table will also show the
modified data.
A DataView
is similar to a view in a database. A data view has restrictions: It cannot be
treated as a table. It cannot be provide a view of joined database objects.
It cannot excludes
columns that exist in the source database.
Creating Data View:
Each DataView
object has a default data view object associated with it. To modify the default
view for a table the default view property is used to reference the view and
then the sorting and filtering properties are enabled.
A DataView
object creates a fixed customized view of a given DataTable object by
default every table in a DataSet has a data view attached to
it.
You can also
explicitly create the data view objects in application.
A DataView
can display customized data from a data table to a windows application by
filtering the data on the basis of a condition.
A DataTable
can have multiple data view objects assigned to it, allowing data to be viewed
in different ways without having to re-read from the database.
You can define
multiple views on the same data table.
Sorting & Filtering Using Data View:
A DataView
provides a sorted or filtered view of data in data table.
To specify a
sorting order on a single or multiple columns, you can use the sort property of
the data view.
To automatically
create a sorting ordered, on the basis of the primary key columns or any other
columns of the database. You can use apply default sort property of the DataView
object.
Dotnetmastery.com is one of the best and ultimate learning recourses for .NET developers. At our website you can learn lots of E-courses in affordable prices. What our Dot Net Mastery courses offering Job focused Training, Fast Track Learning and much. Visit us today at our official website and get best courses today.
ReplyDeleteLearn Entity Framework