EntityBase.GetProperties no in V2

Posts   
 
    
jshallard
User
Posts: 62
Joined: 23-Mar-2005
# Posted on: 05-Sep-2006 11:21:10   

In LLBLGenPro V1 we use the following custom code to establish if an entity has a particular field:


public static bool SafeHasField(EntityBase entity, string fieldName)
    {
        System.ComponentModel.PropertyDescriptorCollection pdc;
        bool hasField = false;

        if(entity != null)
        {
            pdc = entity.GetProperties(null);

            // Find returns null if property is not found.
            if (pdc.Find(fieldName, true) != null)
            {
                hasField = true;
            }
        }
        
        return hasField;
      }

The "GetProperties" Method of EntityBase no longer seems to exist. Can anyone suggest another way to do this (other than simply trying to access field, and catching any errors)?

Thanks for any help

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Sep-2006 12:05:00   

PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(myEntity);

then traverse the properties collection simple_smile

Frans Bouma | Lead developer LLBLGen Pro
jshallard
User
Posts: 62
Joined: 23-Mar-2005
# Posted on: 05-Sep-2006 13:02:13   

Bingo!

Thanks for your prompt reply smile