Table<TEntity> Table<TEntity> Table<TEntity> Table<TEntity> Class

定義

代表基礎資料庫中特定類型的資料表。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>Table<TEntity>Table<TEntity>Table<TEntity>
實作

備註

這個類別可讓您查詢資料表並新增、 移除和附加的物件。This class enables you to query over the table and add, remove, and attach objects.

應用程式可以存取Table<TEntity>執行個體透過GetTable或使用強型別的屬性的強型別DataContextAn 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 Context Context Context

取得已用於擷取此 DataContextTable<TEntity>Gets the DataContext that has been used to retrieve this Table<TEntity>.

IsReadOnly IsReadOnly IsReadOnly 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) Attach(TEntity) Attach(TEntity) Attach(TEntity)

當開放式並行存取檢查需要原始值時,將中斷連接的實體附加至新的 DataContextAttaches a disconnected or "detached" entity to a new DataContext when original values are required for optimistic concurrency checks.

Attach(TEntity, Boolean) Attach(TEntity, Boolean) Attach(TEntity, Boolean) Attach(TEntity, Boolean)

以已修改或未修改的狀態,將實體附加至 DataContextAttaches an entity to the DataContext in either a modified or unmodified state.

Attach(TEntity, TEntity) Attach(TEntity, TEntity) Attach(TEntity, TEntity) 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>) AttachAll<TSubEntity>(IEnumerable<TSubEntity>) AttachAll<TSubEntity>(IEnumerable<TSubEntity>) 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) AttachAll<TSubEntity>(IEnumerable<TSubEntity>, Boolean) AttachAll<TSubEntity>(IEnumerable<TSubEntity>, Boolean) 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>) DeleteAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>) DeleteAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>) DeleteAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>)

將集合中的所有實體置於 pending delete 狀態。Puts all entities from the collection into a pending delete state.

DeleteOnSubmit(TEntity) DeleteOnSubmit(TEntity) DeleteOnSubmit(TEntity) DeleteOnSubmit(TEntity)

將此資料表中的實體置於 pending delete 狀態。Puts an entity from this table into a pending delete state.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

取得可逐一查看集合的列舉值。Gets an enumerator that iterates through the collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetModifiedMembers(TEntity) GetModifiedMembers(TEntity) GetModifiedMembers(TEntity) GetModifiedMembers(TEntity)

傳回已修改成員的陣列,這些成員包含其目前值和原始值。Returns an array of modified members that contain their current and original values.

GetNewBindingList() GetNewBindingList() GetNewBindingList() GetNewBindingList()

建立新清單以繫結至資料來源。Creates a new list for binding to a data source.

GetOriginalEntityState(TEntity) GetOriginalEntityState(TEntity) GetOriginalEntityState(TEntity) GetOriginalEntityState(TEntity)

傳回包含實體之原始狀態的 Table<TEntity> 執行個體。Returns a Table<TEntity> instance that contains the original state of the entity.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InsertAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>) InsertAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>) InsertAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>) InsertAllOnSubmit<TSubEntity>(IEnumerable<TSubEntity>)

將集合的所有實體加入至 pending insert 狀態中的 DataContextAdds all entities of a collection to the DataContext in a pending insert state.

InsertOnSubmit(TEntity) InsertOnSubmit(TEntity) InsertOnSubmit(TEntity) InsertOnSubmit(TEntity)

pending insert 狀態中的實體加入至此 Table<TEntity>Adds an entity in a pending insert state to this Table<TEntity>.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回表示資料表的字串。Returns a string that represents the table.

明確介面實作

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through the collection.

IEnumerable<TEntity>.GetEnumerator() IEnumerable<TEntity>.GetEnumerator() IEnumerable<TEntity>.GetEnumerator() IEnumerable<TEntity>.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through the collection.

IListSource.ContainsListCollection IListSource.ContainsListCollection IListSource.ContainsListCollection IListSource.ContainsListCollection

取得值,表示集合是否為 IList 物件的集合。Gets a value that indicates whether the collection is a collection of IList objects.

IListSource.GetList() IListSource.GetList() IListSource.GetList() 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 IQueryable.ElementType IQueryable.ElementType 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.Expression IQueryable.Expression IQueryable.Expression

取得與這個 IQueryable 執行個體相關聯的運算式樹狀架構。Gets the expression tree that is associated with this instance of IQueryable.

IQueryable.Provider IQueryable.Provider IQueryable.Provider IQueryable.Provider

取得與這個資料來源關聯的查詢提供者。Gets the query provider that is associated with this data source.

IQueryProvider.CreateQuery(Expression) IQueryProvider.CreateQuery(Expression) IQueryProvider.CreateQuery(Expression) IQueryProvider.CreateQuery(Expression)

建構 IQueryable 物件,這個物件可評估由指定的運算式樹狀架構所表示的查詢。Constructs an IQueryable object that can evaluate the query represented by a specified expression tree.

IQueryProvider.CreateQuery<TResult>(Expression) IQueryProvider.CreateQuery<TResult>(Expression) IQueryProvider.CreateQuery<TResult>(Expression) 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) IQueryProvider.Execute(Expression) IQueryProvider.Execute(Expression) IQueryProvider.Execute(Expression)

執行指定之運算式樹狀架構所代表的查詢。Executes the query represented by a specified expression tree.

IQueryProvider.Execute<TResult>(Expression) IQueryProvider.Execute<TResult>(Expression) IQueryProvider.Execute<TResult>(Expression) IQueryProvider.Execute<TResult>(Expression)

執行由指定之運算式樹狀架構所代表的強型別查詢。Executes the strongly-typed query represented by a specified expression tree.

ITable.Attach(Object) ITable.Attach(Object) ITable.Attach(Object) ITable.Attach(Object)

將實體附加至未修改狀態中的 DataContextAttaches an entity to the DataContext in an unmodified state.

ITable.Attach(Object, Boolean) ITable.Attach(Object, Boolean) ITable.Attach(Object, Boolean) ITable.Attach(Object, Boolean)

以已修改或未修改的狀態,將集合的所有實體附加至 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.Attach(Object, Object) ITable.Attach(Object, Object) ITable.Attach(Object, Object) 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) ITable.AttachAll(IEnumerable) ITable.AttachAll(IEnumerable) ITable.AttachAll(IEnumerable)

以已修改或未修改的狀態,將集合的所有實體附加至 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.AttachAll(IEnumerable, Boolean) ITable.AttachAll(IEnumerable, Boolean) ITable.AttachAll(IEnumerable, Boolean) ITable.AttachAll(IEnumerable, Boolean)

以已修改或未修改的狀態,將集合的所有實體附加至 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

ITable.DeleteAllOnSubmit(IEnumerable) ITable.DeleteAllOnSubmit(IEnumerable) ITable.DeleteAllOnSubmit(IEnumerable) ITable.DeleteAllOnSubmit(IEnumerable)

將集合中的所有實體置於 pending delete 狀態。Puts all entities from the collection into a pending delete state.

ITable.DeleteOnSubmit(Object) ITable.DeleteOnSubmit(Object) ITable.DeleteOnSubmit(Object) ITable.DeleteOnSubmit(Object)

將此資料表中的實體置於 pending delete 狀態。Puts an entity from this table into a pending delete state.

ITable.GetModifiedMembers(Object) ITable.GetModifiedMembers(Object) ITable.GetModifiedMembers(Object) ITable.GetModifiedMembers(Object)

傳回已修改成員的陣列,這些成員包含其目前值和原始值。Returns an array of modified members that contain their current and original values.

ITable.GetOriginalEntityState(Object) ITable.GetOriginalEntityState(Object) ITable.GetOriginalEntityState(Object) ITable.GetOriginalEntityState(Object)

擷取特定實體的原始值。Retrieves original values of a given entity.

ITable.InsertAllOnSubmit(IEnumerable) ITable.InsertAllOnSubmit(IEnumerable) ITable.InsertAllOnSubmit(IEnumerable) ITable.InsertAllOnSubmit(IEnumerable)

將集合的所有實體加入至 pending insert 狀態的 DataContextAdds all entities of a collection to the DataContext in an pending insert state.

ITable.InsertOnSubmit(Object) ITable.InsertOnSubmit(Object) ITable.InsertOnSubmit(Object) ITable.InsertOnSubmit(Object)

pending insert 狀態中的實體加入至此資料表。Adds an entity in a pending insert state to this table.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

傳回DataTable,其中包含副本DataRow物件,指定輸入IEnumerable<T>物件其中泛型參數TDataRowReturns 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

Cast<TResult>(IQueryable) Cast<TResult>(IQueryable) Cast<TResult>(IQueryable) Cast<TResult>(IQueryable)

IQueryable 的項目轉換為指定的型別。Converts the elements of an IQueryable to the specified type.

OfType<TResult>(IQueryable) OfType<TResult>(IQueryable) OfType<TResult>(IQueryable) OfType<TResult>(IQueryable)

篩選的項目IQueryable根據指定的型別。Filters the elements of an IQueryable based on a specified type.

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

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

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) 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) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) 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>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) 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) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) 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>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) 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) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) 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>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) 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>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於