IRelatedEnd.Add 方法
定义
将对象添加到相关端。Adds an object to the related end.
重载
| Add(IEntityWithRelationships) |
将对象添加到相关端。Adds an object to the related end. |
| Add(Object) |
将对象添加到相关端。Adds an object to the related end. |
Add(IEntityWithRelationships)
将对象添加到相关端。Adds an object to the related end.
public:
void Add(System::Data::Objects::DataClasses::IEntityWithRelationships ^ entity);
public void Add (System.Data.Objects.DataClasses.IEntityWithRelationships entity);
abstract member Add : System.Data.Objects.DataClasses.IEntityWithRelationships -> unit
Public Sub Add (entity As IEntityWithRelationships)
参数
- entity
- IEntityWithRelationships
添加到集合的对象。An object to add to the collection. entity 必须实现 IEntityWithRelationships。entity must implement IEntityWithRelationships.
注解
Add 方法将对象添加到相关端。The Add method adds an object to the related end. 相关端必须为 EntityCollection<TEntity>。The related end must be an EntityCollection<TEntity>.
如果源对象实现 IEntityWithRelationships 并在中跟踪 ObjectStateManager ,则还会跟踪正在添加的对象。When the source object implements IEntityWithRelationships and is being tracked in the ObjectStateManager, the object being added is also tracked.
RelatedEnd 类显式实现 Add 方法。The RelatedEnd class explicitly implements the Add method. EntityCollection<TEntity> 类使用此实现。The EntityCollection<TEntity> class uses this implementation. 有关详细信息,请参阅 Add。For more information, see Add.
如果相关端是 EntityReference<TEntity> 并且 Value 引用的属性不为 null ,则此方法将引发异常。If the related end is an EntityReference<TEntity> and the Value property of the reference is not null, this method throws an exception.
适用于
Add(Object)
将对象添加到相关端。Adds an object to the related end.
public:
void Add(System::Object ^ entity);
public void Add (object entity);
abstract member Add : obj -> unit
Public Sub Add (entity As Object)
参数
- entity
- Object
添加到集合的对象。An object to add to the collection.
注解
将此方法重载用于不实现的实体类 IEntityWithRelationships 。Use this method overload for entity classes that do not implement IEntityWithRelationships. Add对于实现的实体类,请使用方法 IEntityWithRelationships 。Use the Add method for entity classes that do implement IEntityWithRelationships.
Add 方法将对象添加到相关端。The Add method adds an object to the related end. 相关端必须为 EntityCollection<TEntity>。The related end must be an EntityCollection<TEntity>.
RelatedEnd 类显式实现 Add 方法。The RelatedEnd class explicitly implements the Add method. EntityCollection<TEntity> 类使用此实现。The EntityCollection<TEntity> class uses this implementation. 有关详细信息,请参阅 Add。For more information, see Add.
如果相关端是 EntityReference<TEntity> 并且 Value 引用的属性不为 null ,则此方法将引发异常。If the related end is an EntityReference<TEntity> and the Value property of the reference is not null, this method throws an exception.