Table<TEntity> 类

定义

表示基础数据库中的特定类型的表。Represents a table for a particular type in the underlying database.

generic <typename TEntity>
 where TEntity : classpublic ref class Table sealed : System::Collections::Generic::IEnumerable<TEntity>, System::ComponentModel::IListSource, System::Data::Linq::ITable, System::Linq::IQueryable<TEntity>, System::Linq::IQueryProvider
public sealed class Table<TEntity> : System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource, System.Data.Linq.ITable, System.Linq.IQueryable<TEntity>, System.Linq.IQueryProvider where TEntity : class
type Table<'Entity (requires 'Entity : null)> = class
    interface ITable
    interface IQueryProvider
    interface IListSource
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface IQueryable
Public NotInheritable Class Table(Of TEntity)
Implements IEnumerable(Of TEntity), IListSource, IQueryable(Of TEntity), IQueryProvider, ITable

类型参数

TEntity

表中数据的类型。The type of the data in the table.

继承
Table<TEntity>
实现

注解

利用此类,您可以对表进行查询以及添加、删除和附加对象。This class enables you to query over the table and add, remove, and attach objects.

应用程序可以通过Table<TEntity> GetTable或使用强类型的强类型DataContext属性来访问实例。An application can access a Table<TEntity> instance via GetTable or by using a strongly typed property for the strongly typed DataContext. 也就是说,当设计器生成 DataContext 对象时,它将生成用于表示每个表的属性。That is, when the designer generates a DataContext object, it generates properties to represent each Table. 例如:For example:

[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="SignOffTool")]  
public partial class DataClasses1DataContext : System.Data.Linq.DataContext {  
   public System.Data.Linq.Table<User> Users {  
      get {  
         return this.GetTable<User>();  
      }  
   }  
}  

对于此强类型的 DataContext,可以访问 "用户" 属性以Table<User>获取。For this strongly typed DataContext, you can access the Users property to get Table<User>.

属性

Context

获取已用于检索此 Table<TEntity>DataContextGets the DataContext that has been used to retrieve this Table<TEntity>.

IsReadOnly

获取一个值,该值指示包含在此 Table<TEntity> 实例中的实体类型是否具有主键。Gets a value that indicates whether the type of the entities contained in this Table<TEntity> instance has a primary key.

方法

Attach(TEntity)

如果执行开放式并发检查时需要原始值,请将已断开连接或“已拆离”的实体附加到新的 DataContextAttaches a disconnected or "detached" entity to a new DataContext when original values are required for optimistic concurrency checks.

Attach(TEntity, Boolean)

以修改或未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in either a modified or unmodified state.

Attach(TEntity, TEntity)

通过指定实体及其原始状态,以修改或未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.

AttachAll<TSubEntity>(IEnumerable<TSubEntity>)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

AttachAll<TSubEntity>(IEnumerable<TSubEntity>, Boolean)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

DeleteAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>)

将集合中的所有实体置为 pending delete 状态。Puts all entities from the collection into a pending delete state.

DeleteOnSubmit(TEntity)

将此表中的实体置为 pending delete 状态。Puts an entity from this table into a pending delete state.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

获取能够循环访问集合的枚举器。Gets an enumerator that iterates through the collection.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetModifiedMembers(TEntity)

返回包含当前值和原始值的已修改成员的数组。Returns an array of modified members that contain their current and original values.

GetNewBindingList()

创建用于绑定到数据源的新列表。Creates a new list for binding to a data source.

GetOriginalEntityState(TEntity)

返回包含实体原始状态的 Table<TEntity> 实例。Returns a Table<TEntity> instance that contains the original state of the entity.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InsertAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>)

pending insert 状态将集合中的所有实体添加到 DataContextAdds all entities of a collection to the DataContext in a pending insert state.

InsertOnSubmit(TEntity)

将处于 pending insert 状态的实体添加到此 Table<TEntity>Adds an entity in a pending insert state to this Table<TEntity>.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示表的字符串。Returns a string that represents the table.

显式界面实现

IEnumerable.GetEnumerator()

返回一个循环访问集合的枚举器。Returns an enumerator that iterates through the collection.

IEnumerable<TEntity>.GetEnumerator()

返回一个循环访问集合的枚举器。Returns an enumerator that iterates through the collection.

IListSource.ContainsListCollection

获取一个值,该值指示集合是否为 IList 对象的集合。Gets a value that indicates whether the collection is a collection of IList objects.

IListSource.GetList()

从不实现 IList 本身的对象返回可以绑定到数据源的 IListReturns an IList that can be bound to a data source from an object that does not implement an IList itself.

IQueryable.ElementType

获取在执行与此对象相关联的表达式树时返回的元素类型。Gets the type of the element(s) that are returned when the expression tree associated with this object is executed.

IQueryable.Expression

获取与 IQueryable 的此实例相关联的表达式树。Gets the expression tree that is associated with this instance of IQueryable.

IQueryable.Provider

获取与此数据源相关联的查询提供程序。Gets the query provider that is associated with this data source.

IQueryProvider.CreateQuery(Expression)

构造一个 IQueryable 对象,该对象可计算指定表达式树所表示的查询。Constructs an IQueryable object that can evaluate the query represented by a specified expression tree.

IQueryProvider.CreateQuery<TResult>(Expression)

构造一个 IQueryable<T> 对象,该对象可计算指定表达式树所表示的查询。Constructs an IQueryable<T> object that can evaluate the query represented by a specified expression tree.

IQueryProvider.Execute(Expression)

执行指定表达式树所表示的查询。Executes the query represented by a specified expression tree.

IQueryProvider.Execute<TResult>(Expression)

执行指定表达式树所表示的强类型查询。Executes the strongly-typed query represented by a specified expression tree.

ITable.Attach(Object)

以未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in an unmodified state.

ITable.Attach(Object, Boolean)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.Attach(Object, Object)

通过指定实体及其原始状态,以修改或未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.

ITable.AttachAll(IEnumerable)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.AttachAll(IEnumerable, Boolean)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.DeleteAllOnSubmit(IEnumerable)

将集合中的所有实体置为 pending delete 状态。Puts all entities from the collection into a pending delete state.

ITable.DeleteOnSubmit(Object)

将此表中的实体置为 pending delete 状态。Puts an entity from this table into a pending delete state.

ITable.GetModifiedMembers(Object)

返回包含当前值和原始值的已修改成员的数组。Returns an array of modified members that contain their current and original values.

ITable.GetOriginalEntityState(Object)

检索给定实体的原始值。Retrieves original values of a given entity.

ITable.InsertAllOnSubmit(IEnumerable)

pending insert 状态将集合中的所有实体添加到 DataContextAdds all entities of a collection to the DataContext in an pending insert state.

ITable.InsertOnSubmit(Object)

将处于 pending insert 状态的实体添加到此表。Adds an entity in a pending insert state to this table.

扩展方法

CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Cast<TResult>(IQueryable)

IQueryable 的元素转换为指定的类型。Converts the elements of an IQueryable to the specified type.

OfType<TResult>(IQueryable)

根据指定类型筛选 IQueryable 的元素。Filters the elements of an IQueryable based on a specified type.

SortBy<T>(IQueryable<T>, String)

指定排序顺序。Specifies a sort order.

Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于