Visual Basic (Declaration) | |
---|---|
Public Overloads Function CreateEntity( _ ByVal entityType As Type, _ ByVal entitySetName As String _ ) As Object |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As EntityManager Dim entityType As Type Dim entitySetName As String Dim value As Object value = instance.CreateEntity(entityType, entitySetName) |
C# | |
---|---|
public object CreateEntity( Type entityType, string entitySetName ) |
C++/CLI | |
---|---|
public: Object^ CreateEntity( Type^ entityType, String^ entitySetName ) |
Parameters
- entityType
- Entity type
- entitySetName
- Name of the entity set for the new entity
Return Value
A new instance of the specified entity typeException | Description |
---|---|
System.ArgumentOutOfRangeException | Bad entity type |
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); |
You may either "new" a business object (unless it's Abstract (or MustInherit in Visual Basic), or use one of the overloaded CreateEntity methods. Any new entity has a "detached" EntityAspect.EntityState until added to the EntityManager cache using either IdeaBlade.EntityModel.EntityManager.AddEntity or the object's IdeaBlade.EntityModel.EntityAspect.AddToManager method.
The "entity set" is a construct within the Entity Framework which allows you to logically group entities of the same type. See EntityQuery.EntitySetName for more information. If an entity set name is not provided then the EntityGroup.DefaultEntitySetName is used.
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