Create IEntityField2 based on string name

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 07-May-2005 17:28:51   

Hi,

If I don't have an entity instance but I do have the entity's type and the string name of one of its fields, how can I create the corresponding IEntityFeld2 instance?

Cheers,

Ian.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 08-May-2005 11:58:48   

Ian wrote:

Hi,

If I don't have an entity instance but I do have the entity's type and the string name of one of its fields, how can I create the corresponding IEntityFeld2 instance?

Use: IEntityField2 field = EntityFieldsFactory.CreateEntityFieldsObject(entityType)[fieldname];

Frans Bouma | Lead developer LLBLGen Pro
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 09-May-2005 21:52:32   

Otis wrote:

IEntityField2 field = EntityFieldsFactory.CreateEntityFieldsObject(entityType)[fieldname];

Is this new functionality? I see this now, but don't remember seeing it before (although I may never have looked simple_smile ).

I have a few spots where I create all the fields, then reference the fieldindex by an integer value. Now I can just create a single field (or maybe I always could)?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-May-2005 22:35:56   

psandler wrote:

Otis wrote:

IEntityField2 field = EntityFieldsFactory.CreateEntityFieldsObject(entityType)[fieldname];

Is this new functionality? I see this now, but don't remember seeing it before (although I may never have looked simple_smile ).

this is here since day 1 simple_smile

I have a few spots where I create all the fields, then reference the fieldindex by an integer value. Now I can just create a single field (or maybe I always could)?

This always generates all the fields for an entity, and selects a single one from the list. What you do is what I do here too, I just use the name instead of the index.

You can create a single field of course, by using EntityFieldFactory.Create(fieldenum.fieldname), but you already knew that wink

Frans Bouma | Lead developer LLBLGen Pro