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
|
I just had a thought and decided to throw it out there. What if you could link LightSpeed models together by an association? Like you have two models where an object on one is associated to an object on another model. This could solve the large model problem. At first I thougth the UnitOfWork couldnt handel it but the base unit of work could. The only limitatioin is you wouldnt get an IQueryable<T> from the generated unit of work. You could even have a refactor for split model on an association. What do you guys think? |
|
|
It's funny you should mention that -- it's pretty much what I've been working on for the last couple of days, and the current nightly builds contain a preliminary version of this feature. You can mark an entity as being an "external reference" (via the Is External Reference property, though this may be renamed to Is Link) which means we won't generate code for it. So you can now split a model as follows: 1. Create two model files, say Sales.lsmodel and Logistics.lsmodel. 2. Change their model Name properties to be the same, say MyEnterprise. If you're overriding the namespace, change that to be the same as well. This step is crucial because the "linked models" approach relies on partial classes merging so they have to have the same names and namespaces! 3. Pick one of these, say Sales.lsmodel, to be the "main" model. It doesn't matter which one. In each other file -- in this example, in Logistics.lsmodel -- change the model's Is Secondary Model property to True. This is a technical requirement because there is some code that we have to generate only once or it will cause compiler errors, so we need to pick just one file against which to generate that code: if I can find a way to handle this automatically then I'll get rid of this requirement. 4. Create, say, a PurchaseOrder entity in Sales.lsmodel, and a Shipment in Logistics.lsmodel. We want to have a relationship between these two, so that a PurchaseOrder will have a Shipments collection. 5. Now create a Shipment entity in Sales.lsmodel, and change its Is External Reference (or Is Link) property to True. Drag a one-to-many association from PurchaseOrder to Shipment. 6. Conversely, create a PurchaseOrder entity in Logistics.lsmodel, and change its Is External Reference to True. Again, drag a one-to-many association from PurchaseOrder to Shipment. Notice that the cross-file association needs to be represented in both .lsmodel files. 7. Save everything and compile. You should now have a single unit of work class (MyEnterpriseUnitOfWork) with IQueryable PurchaseOrders and Shipments properties; a PurchaseOrder class with a Shipments property; and a Shipment class with a PurchaseOrder property. So the generated code will look like a unified model even though it's assembled from two files' worth of partial classes. We are still working on this feature so please consider this a sneak preview for now, and expect rough edges or bugs! An important caveat is that you still need to configure the identity type (and, if using database sync, any ID column or table name overrides) on the link: these WON'T get picked up from the linkee. We will try to improve tool support to make it easier to work with (I like your idea of Refactor > Split Model at Association) though this may have to be post-3.1. Also, if you have customised your templates, you may need to make some changes -- these are currently a bit fiddly but I'm hoping to simplify them in tonight's nightly, so you may want to hold off if this is the case. |
|
|
Okay, since writing this I changed some names, so (beginning with the 18 May nightly) look for Is Linked Child and Is Link rather than "Is Secondary Model" and "Is External Reference." And I make no guarantees that these won't change again *grin*. |
|
|
And the nightly will also contain the beginnings of tool support: you'll be able to select an entity in one .lsmodel file, copy it, then go to another file and "Paste as Link." Saves a bit of mucking around with the toolbox. Also, if neither file is marked as Is Linked Child, it will set the target file Is Linked Child automatically for you. |
|