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, I need to add many (hundreds?) of similar (often identical) custom attributes to each of our generated lightspeed Entities. So far the only two ways I can see to do this are: 1) Create a partial class for every Entity and paste the attribute onto it there. 2) Click through every Entity in the designer and use the GUI tool to add custom attributes.
Neither option strikes me as a fun way to spend an afternoon so I wondered if anyone has any alternative ideas? I did try adding an attribute to the generated code file and used "update from source" in the designer. This didn't work: "The selected entities are up to date."
Thanks, Chris |
|
|
|
|
"Update From Source" won't help you here because the "source" refers to the data source, not the source code -- i.e. it is updating the model from the database. Sorry for the confusion. There are a couple of ways to tackle this: 1. Write a script that opens the .lsmodel file as an XML file and goes through adding the custom attribute elements to the XML. You will then be able to re-open the .lsmodel file in the GUI. You will I think need to make a change the the .lsmodel through the GUI in order to force it to regenerate the C#/VB code (just move an entity and then move it back again, that should be enough). 2. Write a Visual Studio macro that opens the .lsmodel file as an XML file, creates a partial class in your project for each entity, and adds the necessary attributes to that partial class. Option 1 is probably the easier of the two unless you're already a bit of a VS macro ninja. You may want to create a couple of sample attributes through the GUI to see how attributes are represented in the XML. Note that if the model continues to evolve you will need to either add attributes by hand as you create entities or create your script so that it can be re-run without duplicating the attributes if an entity already has them. One thing I'd like to do in a future release is provide a customisation capability so that you can say "when I create / generate a new entity I want it to inherit from this base class, have these attributes, etc. etc." That's a bit of a niche feature though so I'm not sure when / if we'll get round to it. |
|
|
|
|
Ah, I'm completely in the "object model first" camp so I ignored the "from Source" option until now. I do remember reading it in the manual now that you mention it :-) I'll probably go for option 1 or just copy and paste into the .lsmodel file depending on exactly how many attributes we end up needing and how similar they are. I hadn't looked in the .lsmodel file before but it makes sense and will be a vast improvement on my initial ideas! Thanks, Chris |
|
|
|