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. 类扩展ObjectQuery<T>类的功能, 以在从ObjectContext访问的类型化实体集的上下文中提供对象上下文功能, 如添加和删除对象。 ObjectSet<TEntity>The 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 的浅表副本。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()

IList 形式返回一个集合,用于数据绑定。Returns the collection as an IList used for data binding.

(Inherited from ObjectQuery)

扩展方法

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) 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) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) 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) 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)

IEnumerable 转换为 IQueryableConverts 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.

适用于