| Visual Basic (Declaration) | |
|---|---|
Public Sub AddEntities( _ ByVal entities As IEnumerable _ ) | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As EntityManager Dim entities As IEnumerable instance.AddEntities(entities) | |
| C# | |
|---|---|
public void AddEntities( IEnumerable entities ) | |
| C++/CLI | |
|---|---|
public: void AddEntities( IEnumerable^ entities ) | |
Parameters
- entities
- Entities to be added.
| Exception | Description |
|---|---|
| System.ArgumentException | Entity already belongs to another EntityManager |
| C# | Copy Code |
|---|---|
DomainModelEntityManager mgr = new DomainModelEntityManager(); // Retrieve an order Order order = mgr.Orders.FirstOrNullEntity(o=> o.OrderID == 1); // Retrieve a product Product product = mgr.Products.FirstOrNullEntity(p => p.ProductID == 1); // Create an OrderDetail OrderDetail dtl = mgr.CreateEntity<OrderDetail>(); // assign key fields dtl.OrderSummary = order; dtl.Product = product; // add the OrderDetail to the EntityManager cache DebugFns.WriteLine("entity state before add = " + dtl.EntityState); dtl.AddToManager(); DebugFns.WriteLine("entity state after add = " + dtl.EntityState); | |
Adds business objects created by the IdeaBlade.EntityModel.EntityManager.CreateEntity``1 method to the EntityManager cache. The objects must have a "detached" EntityAspect.EntityState. The added entities will have an entity state of "Added" after this method completes.
If an entity has an auto-incrementing EntityKey, the EntityManager.GenerateId method is called to create a temporary ID. See the Developers Guide for more information on custom ID generation.
The EntityGroup.EntityChanging and EntityGroup.EntityChanged events fire when this method executes.
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family