Home > .NET Domain Model, Developing Using CodeFluent Entities > What’s the Entity Display Name?

What’s the Entity Display Name?

Having a look to what the WPF Smart-Client Producer generates (producer is still in Beta), you’ll note that the generated screens have their comboboxes directly bound to entity instances without any extra-code:

<ComboBox ItemsSource=”{Binding  Source={StaticResource CustomerCollectionLoadAll}}”
SelectedItem=”{Binding Path=Customer}” />

So, one might ask how does it know which property value to display?

You’ll notice that in the generated Business Object Model, all entity classes are decorated with the following attribute:


As you can see a TypeConverter is specified, and it is set to be the NameTypeConverter provided by the runtime.
The NameTypeConverter provides a simple type converter to display a name for any object.

To do so, it uses the IDisplayable interface, or the ICodeFluentEntity interface or ultimately searches for a property called DisplayName or Name.
It also just so happens that all CodeFluent Entities generated classes implement the ICodeFluentEntity interface which provides a property named EntityDisplayName.

As documented here, by default, the EntityDisplayName of an entity is the first string property declared after the identifier.
However, if ever the collectionKey attribute is used on one of the string typed properties, it will use this collection key.
Finally, you can define the EntityDisplayName property yourself by setting the entityDisplay XML attribute (Is Entity Display in the modeler) on your desired property.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s