This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Guys Probably being too clever for my own good but attempting to use the index property on the base Entity class to get at certain properties and write some 'generic' code. Currently when I do the following protected List<int> CompareSelectedItemsCollectionAndReturnNewItems<T>(string idToFind, List<int> userSelectedItems, EntityCollection<T> currentDomainObjects) where T:Entity the indexer returns "" and int.Parse hates me. Even when I use the "Id" property although I'm typically trying to get a foriegn key. The properties I'm seraching for are there in the watch window so I'm pertty certain the object has loaded and I'm not just getting typo dramas but ..... Should I expect to be able to use this indexer in this manner or should I suck it up and just write a few extra typed methods? Cheers J |
|
|
The indexer on the Entity class is confusing, and doesn't do what you think. It exists to implement the Worst Designed Interface In The History Of APIs Ever, IDataErrorInfo, which stupidly declares the indexer to expect a column name and to return a validation message for that column name. E.g. Product product = GetSomeProduct(); (Please don't hold this awful and confusing API against us -- it's a .NET Framework thing.) Now I think idToFind is the name of the foreign key you want to look up, is that right? If so, what's happening is that the entity is telling you "There's no error on that foreign key." If you want to look up a property value by name, the way to do it is using the Metadata API. This allows you to inspect the fields of an entity, locate fields by name, and get and set field values. For info about the Metadata API, see http://www.mindscapehq.com/documentation/lightspeed/Working-with-Metadata. Let us know if you need any further guidance! |
|
|
O I C Sweet thanks thats just what I wanted .... wouldn't hold it against either ;-D. |
|