Visual Basic (Usage) | ![]() |
---|---|
Dim instance As EntityManager Dim entity As Object instance.AddEntity(entity) |
Parameters
- entity
- Entity to be added.
Exception | Description |
---|---|
System.ArgumentException | Entity already belongs to another EntityManager |
C# | ![]() |
---|---|
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); |
There is no difference between AddEntity and IdeaBlade.EntityModel.EntityAspect.AddToManager. Use either method to add a business object created by the CreateEntity method to the EntityManager cache. The object must have a "detached" EntityState. The added entity will have an entity state of "Added" after this method completes.
If the entity has an auto-incrementing EntityKey, the GenerateId method is called to create a temporary ID. See the Developer Guide for more information on custom ID generation.
The EntityChanging and EntityChanged events fire when this method executes with an EntityAction of EntityAction.Add.
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