ToString()

Mar 2, 2015 at 12:56 AM
I Used ToString() in my Entity Classes so that related entity's world show the information i whant in ComboBoxes and DataGridView rows, with VITA all entityes are Interfaces so i cannot have ToString implementations, is there any workaround for this?

Regards,
Mar 2, 2015 at 1:30 AM
Well, honestly I don't think it's a good practice - to rely on ToString() in UI, it is not recommended usually, but I see the convenience... There is a DisplayAttribute in which you can specify how to format the entity, but you have to call EntityHelper.GetDisplayString(ent) to get this representation. ToString() currently returns internal 'tech' representation (EntityType + PrimaryKey).
After some thinking, I think I will change it and make it return representation from DisplayAttribute. I will push the code tonight, hopefully, or Monday.
So you will just specify Display attr on entity, and this will define the format.
Mar 2, 2015 at 4:19 PM
Done, in new version, just pushed. entity.ToString() is now based on Display attribute.
Mar 2, 2015 at 8:57 PM
How can i use the display attribute?

I have tried [Display("Designacao")] on the entity and it throws

Thanks
Mar 2, 2015 at 8:59 PM
Look at BooksStore samples, entities use this attribute. If you want to reference Property name, enclose it in {}, like [Display("{FirstName} {LastName}")]