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
|
How do i set a ThroughAssociation property to be virtual? I tried marking both relations to the intermediate property as virtual ext. This is for testing purposes. |
|
|
That's currently not supported in the designer; you'd need to define the ThroughAssociation in a partial class instead. I'll look at getting this feature added; how critical is it for you? |
|
|
Thank you for your answer. Does this workaround affect any features lightspeed's code generator might provide (validation, logging ext.)? If the workaround you suggested has implications or maybe in the future you would add cool features which require modifications to the property code this might be more of a problem. Otherwise it would be a nice thing to have for easier testability (and maybe consistency also). If not than that would be a good thing to add as well (even won't mind going through XML config for that). I have to say, it's too bad the CLR doesn't have a built-in runtime interception mechanism.. |
|
|
It means you won't be able to configure anything on the ThroughAssociation through the designer. But there's not much to configure on TAs anyway so I don't think you'll be losing out. It won't affect validation, logging etc. because the code you write by hand will be exactly the same as what the designer would generate except for the additional "virtual" keyword. (At runtime, LightSpeed doesn't know whether the code was written by hand or generated by the designer.) But you're right, it would be nice to have this in the designer for consistency and convenience, and so that it automatically picks up any changes or bug fixes; it's just a matter of prioritising! Re setting all properties to virtual: no, this is not possible at the moment, but you can hack it by running a script over the .lsmodel file. This is just a XML file so you can easily pick out all <entityProperty /> elements and change their inheritance attribute. You will need to reopen the file in the designer and save it (e.g. move an element a couple of pixels and save) in order to regenerate the code after doing this. You could also do this by editing the code generation templates to ignore the Inheritance setting and always make things virtual, though this has maintenance implications; let me know if you want more info about this. |
|
|
Good to hear that won't affect nothing. Please let me know if you add that to the designer (BTW- this is more important than having all properties marked virtual by default)..
|
|