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
|
Hello, We have to update the property of a filtered list of Entities (EntityCollection). The filter and the name of the property is only known at runtime, because the user can change the filter dynamically (type a SQL-where clause in a TextBox) and determine which property is to be updated (propertynames are in a ComboBox). Example: set property 'Status' to 'X' for all People (Entity) where "City = 'A' and Age = '30'". I would like to do something like this in my code (People is the filtered list (List of Person Entity objects):
In this way I can dynamically change the property to be updated. Is there any way I can do this? Thanks in advance, Kind regards, L. Kuiper Acsense Software |
|
|
In terms of applying the filter dynamically you can build up a QueryExpression for use with a Query object via string values (e.g. Entity.Attribute(string) == value), you can use the logical and operator to combine multiple criteria to build up the required filter. In terms of updating an object properties based on a string you could achieve this by reflection (e.g. object.GetType().GetProperty(string)) and then call SetValue on the PropertyInfo assuming its valid. You will need to cater for not locating a valid property and also handle exceptions which may be thrown when calling SetValue (e.g. conversion failure of the assigned value) so it would be sensible to build up some wrappers around this to cater for the various scenarios you might encounter here.
|
|