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
|
is there a way to extend the Entity class with attached behavior ? I use this technique for UI elements but getting a compiler problem when using it on class entity. I do not want to subclass for this use because it would require too many subclasses for the same thing. Right now I have modified the source for this but I do not want to keep it there and take this into version control. I do not want to touch the sources unless I really have to ... thanks gmd |
|
|
Can you elaborate on what you are trying to extend Entity to do? We do have some hooks available for applying custom behavior in response to events but it sounds like you might be trying to do something a little more specific in which case you would need to modify the source directly and maintain a custom build of LightSpeed.
|
|
|
I am using the generated classes as direct input to some viewmodel classes, which require additional properties for each data class. Some of these properties are class specific and this is where I use the partial class to extend the Lightspeed generated class. Some of the properties are common to ALL or many data classes (IsSelected, IsAccumulated, IsNoteAttached and other application specific status fields and properties which are ALL marked as TRANSIENT). I also have some events specific to my application, which I like to add to Entity. Another option is a template file (some kind of include file) which is simply included in the generated version. This would create redundant source code but still better than doing a custom lightspeed version regards gmd |
|
|
Have you looked at using a base class for your entities? If so what was not going to work that would lead you to extending Entity? From what you have described a combination of using the partials and a base class for your entities should provide what you need :)
|
|
|
What do you mean by base class ? and how should it work with generated entity classes ? thanks gmd |
|
|
Have a read of the "Implementing Common Services in a Base Class" section in http://www.mindscapehq.com/documentation/lightspeed/Domain-Modelling-Techniques/Inheritance Here is a quick example: In this example I created 4 entitites, for EntityBase I set the Inheritance property to Abstract to make it an abstract base class and then connected the other 3 entities to EntityBase with the Inheritance connector. The relationship for each of these was set to Concrete Table Inheritance. You can then implement the shared functionality and events in EntityBase by extending the generated partial class in a new code file.
|
|
|
Jeremy, thanks for the effort and clarification .. I know what a base class is .. in my world it is called a super class but this does not solve my problem ... maybe I do not understand something right or do not know how to use light speed correctly but I do not know how to relate the base class concept to the Mindscape.Lightspeed.Entity class I am using the generated Entity classes in my code directly .. I do not define another layer of so called "business objects" which would handle what you are saying. I am programming on a tool level (meta level) and my business objects are more or less the db tables. I do not have a need for a level in between hence the question to extend Entity directly . Does that make better sense now ? thanks gmd |
|
|
Sorry I must be misunderstanding what you are trying to do. You mentioned you want to add common properties (e.g. IsSelected, IsAccumulated, IsNoteAttached) which are available on all of your entities as well as application specific events which are a shared concern. Now you will be able to achieve both of those by using an abstract base class in your model and implementing the shared concerns there. When this maps to the database tables, each derived entity will have its own table because we are using concrete table inheritance and each of the shared properties would be defined in each entities concrete database table, so from the database perspective it would look like a set of discrete tables which happen to have some similar columns. Within your domain model you are just inheriting from the abstract base (which in turn is inheriting from Entity). Can you elaborate on what is not going to work with this approach and why you would need to directly inherit off Entity instead? I think there must be a bit of understanding about your model or approach which I am missing which is important as to why you are looking to use Entity directly rather than leveraging an abstract base class for the shared concerns.
|
|