Custom Properties

Posts   
 
    
staleb
User
Posts: 19
Joined: 30-Jan-2007
# Posted on: 06-Mar-2007 14:44:41   

Hi I'm writing some custom code in the DataAccessAdapter.

In the: protected override void OnSaveEntityComplete(IActionQuery saveQuery, IEntity2 entityToSave)

I want to check the custom properties of of the entityToSave. This to check if I should do some action here or not.

But I don't seem to be able to retrive thees values in code! Any Ideas?

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 06-Mar-2007 16:47:04   

Hi,

you can access the custom properties of your entity instance through the properties: FieldCustomPropertiesOfType and CustomPropertiesOfType as suggested in the manual.

Now these properties are exposed by EntityBase2, not IEntity2 (they probably should?)

Simply cast your IEntity2 to EntityBase2, which should be alright, and you'll get the corresponding properties.

Cheers

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 07-Mar-2007 09:38:00   

Good point, I'll expose them in the interfaces.

Frans Bouma | Lead developer LLBLGen Pro
Ben
User
Posts: 8
Joined: 07-Feb-2005
# Posted on: 10-May-2007 16:04:53   

Could you also do the same for IEntity? I'm trying to use this property in a generic method (first few lines):


    private void ExportCollectionToExcel<T>(ExcelWorksheet worksheet, EntityCollectionBase<T> collection)
        where T:EntityBase, IEntity, new()
    {
        T entity = new T();

        foreach (KeyValuePair<string, Dictionary<string, string>> fieldCustomProperties in
            entity.FieldCustomPropertiesOfType)

The above does not work because FieldCustomPropertiesOfType is defined separately for each entity. I'll work around it now by passing the entity's FieldCustomProperties collection as a parameter but having this completely generic would be better ofcourse.

Last question: will you change this in 2.0?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 11-May-2007 11:03:36   

These will be exposed in the IEntity and IEntity2 interfaces in the upgrade currently in development. We don't make architectural/interface changes to released versions, so no I won't add this to v2.0. the upgrade is free for 2.0 customers, so you're recommended to upgrade once it's available.

Frans Bouma | Lead developer LLBLGen Pro
Ben
User
Posts: 8
Joined: 07-Feb-2005
# Posted on: 11-May-2007 11:39:13   

Ok, I'll wait for 2.1. Thanks for your reply.