Custom properties

Posts   
 
    
Posts: 69
Joined: 24-Jun-2008
# Posted on: 25-Jun-2008 14:52:34   

Hi,

I have a user table with the following fields:

ContactTitle ContactName ContactSurName

In my code, everytime I want to represent the user, I have to use string.Format to specify the full customer representation.

Is it possible to create some kind of combination of fetched entities, for example:


public string Contact
{
    get
    {
        return string.Format("{0}{1}{2}", 
            string.Format("{0}{1}", ContactTitle, (ContactTitle.Trim() != "") ? " " : ""),
            string.Format("{0}{1}", ContactName, (ContactName.Trim() != "") ? " " : ""),
            string.Format("{0}{1}", ContactSurName, (ContactSurName.Trim() != "") ? " " : ""));
    }
}

Best regards,

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 25-Jun-2008 16:11:38   

Add the above code as a cutom property in the generated entity class. Better to use a partial class file to add this property.

Posts: 69
Joined: 24-Jun-2008
# Posted on: 25-Jun-2008 16:14:09   

But as soon as I regenerate the DataLayer, my changes are lost. I will add it as a partial class to prevent this from happening.

I was just curious if this was possible in the designer. Maybe it's a good idea to implement easy custom properties in de designer.

Best regards,