Export (0) Print
Expand All

DataContext.Translate Method (Type, DbDataReader)

Converts an existing DbDataReader to objects.

Namespace:  System.Data.Linq
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

public IEnumerable Translate(
	Type elementType,
	DbDataReader reader
)

Parameters

elementType
Type: System.Type

The type of the IEnumerable<T> to be returned.

The algorithm for matching columns in the result to fields and properties in the object works as follows:

If a field or property is mapped to a particular column name, that column name is expected in the resultset.

If a field or property is not mapped, a column with the same name as the field or property is expected in the resultset.

The comparison is performed by looking for a case-sensitive match first. If this match is not found, a subsequent search is occurs for a case-insensitive match.

The query must return all the tracked fields and properties of the object (except those that are loaded on a deferred basis) when all the following conditions are true:

T is an entity explicitly tracked by the DataContext.

ObjectTrackingEnabled is true.

The entity has a primary key.

Otherwise an exception is thrown.

reader
Type: System.Data.Common.DbDataReader

The IDataReader to be converted.

Return Value

Type: System.Collections.IEnumerable
A list of objects returned by the conversion.

.NET Framework

Supported in: 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft