This project is read-only.

Title() method when preexisting Title property

Apr 25, 2012 at 2:32 PM

Hi there.

I am building on an existing database.

There is an Individual table / entity with a property called Title. Thus, I cannot at a Title() method for NO that will build the title dynamically for the Individual entity.

Is the only way to cope with this scenario to rename the Title property on the entity in the model?

It would have been nice if I could mark up another arbitrary method with the [Title] attribute.

Apr 25, 2012 at 2:49 PM

The simplest thing is just to over-write the ToString() method to return the string you want for the title. In the absence of a Title() method (or Title attribute on a property), the framework will use the ToString method.

Another option is to add a derived property (getter only) that returns the desired title string, and annotate this with the Title attribute. 

Apr 25, 2012 at 3:27 PM

Ah, Both great solutions, although I like the second one more. (And it is so obvious, actually).

Thanx much!