Create Instance of Entity By Entity name (Using Adopter)

Posts   
 
    
Posts: 24
Joined: 26-May-2011
# Posted on: 06-Jun-2011 09:37:15   

Hello I am using Adopter service; I required creating an instance of entity by using its name (as String).

Thanks you.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Jun-2011 11:03:17   

Very similar to the code I've linked to in your previous thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=19901

This time IEntityFactory2.CreateEntityCollection() will return IEntityCollection2.

Posts: 24
Joined: 26-May-2011
# Posted on: 06-Jun-2011 12:06:06   

Actually I required only an Entity; not an Entity Collection. On run time I have Entity name and its Primary key value; on the basis of two parameters I want to create an Entity.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Jun-2011 15:52:39   

Here is what the code should look like:

var entityType = (EntityType)Enum.Parse(typeof(EntityType), "Entity-Name", false);
var myEntity = GeneralEntityFactory.Create(entityType);
adapter.FetchNewEntity(myEntity.GetEntityFactory(), yourFilter);
Posts: 24
Joined: 26-May-2011
# Posted on: 07-Jun-2011 08:33:43   

It is amazing, Thanks you.