ObjectSet<TEntity> ObjectSet<TEntity> ObjectSet<TEntity> ObjectSet<TEntity> Class

定義

代表類型實體集,用來執行建立、讀取、更新和刪除作業。Represents a typed entity set that is used to perform create, read, update, and delete operations.

generic <typename TEntity>
 where TEntity : classpublic ref class ObjectSet : System::Data::Objects::ObjectQuery<TEntity>, System::Collections::Generic::IEnumerable<TEntity>, System::Data::Objects::IObjectSet<TEntity>, System::Linq::IQueryable<TEntity>
public class ObjectSet<TEntity> : System.Data.Objects.ObjectQuery<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.Data.Objects.IObjectSet<TEntity>, System.Linq.IQueryable<TEntity> where TEntity : class
type ObjectSet<'Entity (requires 'Entity : null)> = class
    inherit ObjectQuery<'Entity (requires 'Entity : null)>
    interface IObjectSet<'Entity (requires 'Entity : null)>
    interface IQueryable<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IQueryable
Public Class ObjectSet(Of TEntity)
Inherits ObjectQuery(Of TEntity)
Implements IEnumerable(Of TEntity), IObjectSet(Of TEntity), IQueryable(Of TEntity)

類型參數

TEntity

實體類型。The entity type.

繼承
實作

備註

ObjectSet<TEntity>類別可讓您操作的具類型的實體,而不需要指定實體集名稱當做每個方法呼叫的引數集。The ObjectSet<TEntity> class allows you to operate on a typed entity set without having to specify the entity set name as an argument to each method call. ObjectSet<TEntity>類別會擴充功能ObjectQuery<T>類別,以提供物件內容的功能,例如新增和刪除物件內容中的具型別實體集從存取ObjectContextThe ObjectSet<TEntity> class extends the functionality of the ObjectQuery<T> class to provide object context functionality, such as adding and deleting objects, in the context of a typed entity set that is accessed from the ObjectContext.

屬性

CommandText CommandText CommandText CommandText

傳回查詢的命令文字。Returns the command text for the query.

(Inherited from ObjectQuery)
Context Context Context Context

取得與這個物件查詢相關聯的內容物件。Gets the object context associated with this object query.

(Inherited from ObjectQuery)
EnablePlanCaching EnablePlanCaching EnablePlanCaching EnablePlanCaching

取得或設定值,這個值會指出是否應該快取查詢計畫。Gets or sets a value that indicates whether the query plan should be cached.

(Inherited from ObjectQuery)
EntitySet EntitySet EntitySet EntitySet

取得這個 ObjectSet<TEntity> 執行個體所表示之實體集的中繼資料。Gets the metadata of the entity set represented by this ObjectSet<TEntity> instance.

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

取得值,這個值指出查詢所傳回的集合是否包含集合物件。Gets a value that indicates whether the collection returned by the query contains collection objects.

(Inherited from ObjectQuery)
IQueryable.ElementType IQueryable.ElementType IQueryable.ElementType IQueryable.ElementType

取得這個查詢執行個體的結果項目型別。Gets the result element type for this query instance.

(Inherited from ObjectQuery)
IQueryable.Expression IQueryable.Expression IQueryable.Expression IQueryable.Expression

取得描述這個查詢的運算式。Gets the expression describing this query.

(Inherited from ObjectQuery)
IQueryable.Provider IQueryable.Provider IQueryable.Provider IQueryable.Provider

取得與這個查詢執行個體相關聯的 LINQ IQueryProviderGets the LINQ IQueryProvider associated with this query instance.

(Inherited from ObjectQuery)
MergeOption MergeOption MergeOption MergeOption

取得或設定從查詢傳回的物件如何加入至內容物件。Gets or sets how objects returned from a query are added to the object context.

(Inherited from ObjectQuery)
Name Name Name Name

取得或設定這個物件查詢的名稱。Gets or sets the name of this object query.

(Inherited from ObjectQuery<T>)
Parameters Parameters Parameters Parameters

取得這個物件查詢的參數集合。Gets the parameter collection for this object query.

(Inherited from ObjectQuery)

方法

AddObject(TEntity) AddObject(TEntity) AddObject(TEntity) AddObject(TEntity)

將物件加入至目前實體集中的物件內容。Adds an object to the object context in the current entity set.

ApplyCurrentValues(TEntity) ApplyCurrentValues(TEntity) ApplyCurrentValues(TEntity) ApplyCurrentValues(TEntity)

將純量值從提供的物件複製到 ObjectContext 中具有相同索引鍵的物件。Copies the scalar values from the supplied object into the object in the ObjectContext that has the same key.

ApplyOriginalValues(TEntity) ApplyOriginalValues(TEntity) ApplyOriginalValues(TEntity) ApplyOriginalValues(TEntity)

設定 OriginalValuesObjectStateEntry 屬性,以符合所提供物件的屬性值。Sets the OriginalValues property of an ObjectStateEntry to match the property values of a supplied object.

Attach(TEntity) Attach(TEntity) Attach(TEntity) Attach(TEntity)

將物件或物件圖形附加至目前實體集中的物件內容。Attaches an object or object graph to the object context in the current entity set.

CreateObject() CreateObject() CreateObject() CreateObject()

建立新的實體型別物件。Creates a new entity type object.

CreateObject<T>() CreateObject<T>() CreateObject<T>() CreateObject<T>()

建立指定類型的執行個體。Creates an instance of the specified type.

DeleteObject(TEntity) DeleteObject(TEntity) DeleteObject(TEntity) DeleteObject(TEntity)

將物件標記為待刪除。Marks an object for deletion.

Detach(TEntity) Detach(TEntity) Detach(TEntity) Detach(TEntity)

從物件內容中移除物件。Removes the object from the object context.

Distinct() Distinct() Distinct() Distinct()

將查詢限制為唯一的結果。Limits the query to unique results.

(Inherited from ObjectQuery<T>)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
Except(ObjectQuery<T>) Except(ObjectQuery<T>) Except(ObjectQuery<T>) Except(ObjectQuery<T>)

根據另一個物件查詢的結果,透過排除結果限制查詢結果。Limits the query results by excluding results based on the results of another object query.

(Inherited from ObjectQuery<T>)
Execute(MergeOption) Execute(MergeOption) Execute(MergeOption) Execute(MergeOption)

使用指定的合併選項執行物件查詢。Executes the object query with the specified merge option.

(Inherited from ObjectQuery<T>)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetResultType() GetResultType() GetResultType() GetResultType()

傳回查詢之結果型別的相關資訊。Returns information about the result type of the query.

(Inherited from ObjectQuery)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
GroupBy(String, String, ObjectParameter[]) GroupBy(String, String, ObjectParameter[]) GroupBy(String, String, ObjectParameter[]) GroupBy(String, String, ObjectParameter[])

依據指定的準則,分組查詢結果。Groups the query results by the specified criteria.

(Inherited from ObjectQuery<T>)
Include(String) Include(String) Include(String) Include(String)

指定要包含在查詢結果中的相關物件。Specifies the related objects to include in the query results.

(Inherited from ObjectQuery<T>)
Intersect(ObjectQuery<T>) Intersect(ObjectQuery<T>) Intersect(ObjectQuery<T>) Intersect(ObjectQuery<T>)

透過僅包含存在另一個物件查詢中的結果,限制查詢結果。Limits the query results by including only the results that exist in another object query.

(Inherited from ObjectQuery<T>)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
OfType<TResultType>() OfType<TResultType>() OfType<TResultType>() OfType<TResultType>()

將查詢限制為只有特定型別的結果。Limits the query to only results of a specific type.

(Inherited from ObjectQuery<T>)
OrderBy(String, ObjectParameter[]) OrderBy(String, ObjectParameter[]) OrderBy(String, ObjectParameter[]) OrderBy(String, ObjectParameter[])

依據指定的準則,排序查詢結果。Orders the query results by the specified criteria.

(Inherited from ObjectQuery<T>)
Select(String, ObjectParameter[]) Select(String, ObjectParameter[]) Select(String, ObjectParameter[]) Select(String, ObjectParameter[])

將查詢結果限制為只有定義在指定之投影中的屬性。Limits the query results to only the properties that are defined in the specified projection.

(Inherited from ObjectQuery<T>)
SelectValue<TResultType>(String, ObjectParameter[]) SelectValue<TResultType>(String, ObjectParameter[]) SelectValue<TResultType>(String, ObjectParameter[]) SelectValue<TResultType>(String, ObjectParameter[])

將查詢結果限制為只有投影中指定的屬性。Limits the query results to only the property specified in the projection.

(Inherited from ObjectQuery<T>)
Skip(String, String, ObjectParameter[]) Skip(String, String, ObjectParameter[]) Skip(String, String, ObjectParameter[]) Skip(String, String, ObjectParameter[])

依據指定的準則,排序查詢結果,並且略過指定的結果數目。Orders the query results by the specified criteria and skips a specified number of results.

(Inherited from ObjectQuery<T>)
Top(String, ObjectParameter[]) Top(String, ObjectParameter[]) Top(String, ObjectParameter[]) Top(String, ObjectParameter[])

將查詢結果限制為指定的項目數。Limits the query results to a specified number of items.

(Inherited from ObjectQuery<T>)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
ToTraceString() ToTraceString() ToTraceString() ToTraceString()

傳回要針對資料來源執行的命令。Returns the commands to execute against the data source.

(Inherited from ObjectQuery)
Union(ObjectQuery<T>) Union(ObjectQuery<T>) Union(ObjectQuery<T>) Union(ObjectQuery<T>)

結合此查詢的結果與另一個物件查詢的結果,但不包含任何重複項目。Combines the results of the query with the results of another object query, without any duplicates.

(Inherited from ObjectQuery<T>)
UnionAll(ObjectQuery<T>) UnionAll(ObjectQuery<T>) UnionAll(ObjectQuery<T>) UnionAll(ObjectQuery<T>)

結合此查詢的結果與另一個物件查詢的結果,而且包括所有重複項目。Combines the results of the query with the results of another object query, including all duplicates.

(Inherited from ObjectQuery<T>)
Where(String, ObjectParameter[]) Where(String, ObjectParameter[]) Where(String, ObjectParameter[]) Where(String, ObjectParameter[])

將查詢限制為符合指定之篩選準則的結果。Limits the query to results that match specified filtering criteria.

(Inherited from ObjectQuery<T>)

明確介面實作

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

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

(Inherited from ObjectQuery)
IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator() IEnumerable<T>.GetEnumerator()

傳回逐一查看查詢結果的列舉程式。Returns an enumerator that iterates through the results of the query.

(Inherited from ObjectQuery<T>)
IListSource.GetList() IListSource.GetList() IListSource.GetList() IListSource.GetList()

傳回集合當做用於資料繫結 (Data Binding) 的 IListReturns the collection as an IList used for data binding.

(Inherited from ObjectQuery)

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.

適用於