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 it possible to set an entity to have a custom base class, e.g. EntityBase, through the LightSpeed designer? The dropdown only allows entities that are defined in the designer. |
|
|
This isn't currently possible. I have logged a feature request for it. A partial workaround is to define a vacuous EntityBase class in the designer, without any properties, and then provide all of your custom implementation in a partial class. You can then use EntityBase as a base class in the normal way (selecting Concrete Table Inheritance rather than Single Table Inheritance). Of course the downside of this is that you get a lot of inheritance arrows cluttering up the diagram. |
|
|
In which a seemingly trivial feature turns out to be excruciatingly painful to implement... An experimental build of this will be in the next nightly. To register an external class, go into the LightSpeed Model Explorer, right-click the model node and choose Add External Class Reference. Enter the (namespace-qualified) type name of the class, e.g. Mindscape.Tests.WonderEntity. To specify that an entity should use your external class as a base class, choose the entity and go to Base Class in the properties window. (I.e. you can't use the Inheritance tool with external classes.) You will probably see some visual glitches -- specifically you will probably see "bridges" in your arrows where there shouldn't be any. You may also find that, under some circumstances, inheritance arrows are not redrawn if you change an entity's base class from an external class to another entity. (To work around this, set the entity's base class to None, then draw the inheritance arrow using the toolbox.) We will be working on remedying these. As mentioned we have had a few issues implementing this feature so please let us know about any problems and we would advise keeping a backup of the installer for your current build just in case! I expect that you would also like to be able to specify your class as the default base class for newly created entities and I will try to add this feature in the near future. |
|
|
Hi This feature works great but the designer has disabled updating those entities from the database in the designer. Since the entity is just inheriting from a custom .NET class is there any reason why it needs to be disabled? Updating the model from the database is very useful :) |
|
|
The problem is that that "custom .NET class" is opaque to the designer. But it's still an entity, and you could have stuffed it chock full of Important Stuff. Perhaps all your entities have a Code attribute, so you decided to shove that in the base class. Or perhaps your base class is SoftDeleteEntity and centralises the DeletedOn field. So we might add a Code field to or set the Soft Delete property of the designer (derived) entity, not realising that actually these are already handled by the base type, causing (a) confusion and (b) compilation errors (due to property shadowing). We could of course assume that the base type is stateless (or that any state is transient), but that assumption is difficult to enforce and to communicate. We're open to ideas though -- I'd definitely like to get rid of the limitation! |
|
|
Right now it just tells you that it is not allowed. Perhaps you should give a warning that the entities won't be automatically be updated but provide a UI to allow a user to selectively choose inherited entities to update anyway. |
|
|
Very well, Mister Bond, you win this round... From tonight's nightly (16 Jan) the designer will include entities with external base classes in synchronisation. When it tries to figure out what has changed, it will assume that that the external base class does not have anything to contribute, i.e. that the base class contains no persistent state. It will put up a warning message listing the entities that have external base classes and for which update detection is therefore suspect. (The UI may change in future to provide smarter or more fine grained selection or confirmation, but hopefully this will address your immediate pain point.) Please let us know if you run into any problems. |
|