Прочетете на английски Редактиране

Споделяне чрез


DataContext.GetTable Method

Definition

Overloads

GetTable(Type)

Returns a collection of objects of a particular type, where the type is defined by the type parameter.

GetTable<TEntity>()

Returns a collection of objects of a particular type, where the type is defined by the TEntity parameter.

GetTable(Type)

Returns a collection of objects of a particular type, where the type is defined by the type parameter.

C#
public System.Data.Linq.ITable GetTable(Type type);

Parameters

type
Type

The type of the objects to be returned.

Returns

A collection of objects defined by the type parameter.

Remarks

This is a weakly typed version of GetTable. It is important to have a weakly typed version because it is a relatively common practice to construct queries dynamically. It would be inconvenient to force the application to use reflection to call the correct generic method.

If there is no collection for a particular type, an exception is thrown.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

GetTable<TEntity>()

Returns a collection of objects of a particular type, where the type is defined by the TEntity parameter.

C#
public System.Data.Linq.Table<TEntity> GetTable<TEntity>() where TEntity : class;

Type Parameters

TEntity

The type of the objects to be returned.

Returns

A collection of objects defined by the TEntity parameter.

Remarks

This method is the main entry point for querying. When a strongly typed DataContext is created, new generated properties encapsulate calls to this method. For example, a Customers property is generated that returns GetTable<Customer>.

If there is no collection for a particular type, an exception is thrown.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1