ADO
is the only way to work around a server cursor. ADO provides a schema
management API to .Net 1.x. But ADO data (recordset) can’t be directly bound to
ASP.NET controls.
Accessing SQL Server by using the managed provider for OLE DB adds overhead because the objects called must pass through the COM interop layer.
OLDB
provider do not work with those implementing OLEDB 2.5 interfaces for
semistructured and hierarchal rowset that includes Exchange (EXOLEDB) and Internet
Publishing (MSDAIPP).
Linq
Data Source:
There
are five types of linq datasources:
Linq-to-SQL,
Linq-to-Objects, Linq-to-XML, and Linq-to-DataSet, and
Linq-to-Entities.
LinqDataSource
provide the following properties:
AutoGenerateOrderByClause (by using
OrderByParameterCollection),
AutoGenerateWhereClause (By using
WhereParameterCollection),
AutoPage, AutoSort,
(They automatically enable Page sorting for GridView etc if enabled)
ContextTypeName (Class name), EnableDelete,
EnableInsert, EnableUpdate, GroupBy, OrderBy, Select,
StoreOriginalValuesInViewState,
TableName (Property/table
name returning IEnumerable source), Where
public class Employee
{
public
string sName { get;set; }
public
string FName { get;
set; }
public
string LName { get;
set; }
}
public class SimpleList
{
public
static List<Employee> GetData {
get{
return new List<Employee>
{
new Employee {
FName="Mubbasher", LName="Mukhtar", sName="MR"},
new Employee {
FName="Asad", LName="Mukhtar", sName="MR"}};
}
}
}
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="SimpleList" TableName="GetData"
Select="new ( sName,FName )" >
</asp:LinqDataSource>
Providing
Rich Selection Statement:
<asp:LinqDataSource
ID="LinqDataSource1" runat="server"
ContextTypeName="NorthwindDataContext"
TableName="Customers" OnSelecting="LinqDataSource1_Selecting"
/>
private
NorthwindDataContext db;
protected
void Page_Init(object sender, EventArgs e)
{
db = new NorthwindDataContext();
LinqDataSource1.Selecting += new
EventHandler<LinqDataSourceSelectEventArgs>( LinqDataSource1_Selecting);
}
protected
void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs
e)
{
var countries = (from c in db.Customers
select new {
c.Country }).Distinct();
e.Result = countries;
}
var data = from o
in orders
join c in
customers
on o.Field<string>("CustomerID")
equals
c.Field<string>("CustomerID")
where
o.Field<DateTime>("OrderDate").Year == 1998 &&
o.Field<DateTime>("OrderDate").Month
== 1 &&
o.Field<DateTime>("OrderDate").Day
< 10
select new
{OrderID=o.Field<int>("OrderID"),
Company=c.Field<string>("CompanyName")};
Linq-To-Object
works
only for those implementing IEnumerable and IQueryable
interfaces. Almost all built-in collections implement these interfaces.