Label text or Caption for entity

Posts   
 
    
Posts: 94
Joined: 23-Aug-2006
# Posted on: 14-May-2007 01:45:20   

Is there a way to configure an entity to hold a caption or label text per property. For example Customer.FirstName ought to display as First Name when used by an LLBLGen Datasource or other built in mechanism that allows the binding of entities to controls. In other words something similar to what a typed view allows but for an entity.

Thanks Thomas

worldspawn avatar
worldspawn
User
Posts: 321
Joined: 26-Aug-2006
# Posted on: 14-May-2007 03:23:00   

I don't think so. You can assign custom properties to an entity field however these arn't exposed on EntityField2.

You could use this function to evaluate the field name at runtime. This will turn FirstName into First Name, AccountId into Account Id etc.


public static string GetFriendlyName(string name){
    Regex acronym = new Regex("^[A-Z0-9]+(Id)?$");
    Regex exp = new Regex("(\\w)([A-Z])"),
        idExp = new Regex("(\\w)Id$");

    if (idExp.IsMatch(name))
    {
        if (acronym.IsMatch(name))
            return idExp.Replace(name, "$1");

        return exp.Replace(idExp.Replace(name, "$1"), "$1 $2");
    }

    if (acronym.IsMatch(name))
        return name;

    return exp.Replace(name, "$1 $2");
}

worldspawn avatar
worldspawn
User
Posts: 321
Joined: 26-Aug-2006
# Posted on: 14-May-2007 05:39:12   

Actually each entity has this property.


CustomerEntity.FieldsCustomProperties

The key is the name of the field, which will return another string dictionary of properties and values for that field. In LLBL Explorer if you open the field list, click on a field you'll see a custom properties tab which u can then add to.

I'd still argue that a runtime solution is more favourable, cause otherwise ur stuck entering (and maintaining) all those custom properties. Also i dunno how easy it will be for you to access those dictionaries as part of the databinding thingymajig.

P.S. I didn't check any of this, it's 100% assumption simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14987
Joined: 21-Aug-2005
# Posted on: 14-May-2007 09:03:43