ALinq

Linq To Access, MS SQL, SQLite, MySQL, Oracle, Firebird, DB2, PostgreSQL ......

ALinq Document > Programming Guide > Querying the Database

Retrieve Information As Read Only

When you do not intend to change the data, you can increase the performance of queries by seeking readonly results.

Example

The following code retrieves a read-only collection of employee hire dates.
var db = new AccessNorthwind(@"c:\northwind.mdb");

db.ObjectTrackingEnabled = false;
IOrderedQueryable<Employee> hireQuery =
    from emp in db.Employees
    orderby emp.HireDate
    select emp;

foreach (Employee empObj in hireQuery)
{
    Console.WriteLine("EmpID = {0}, Date Hired = {1}",
        empObj.EmployeeID, empObj.HireDate);
}
Dim db = New AccessNorthwind("c:\northwind.mdb")

db.ObjectTrackingEnabled = False
Dim hireQuery As IOrderedQueryable(Of Employee) = _
        From emp In db.Employees() _
        Order By emp.HireDate _
        Select emp