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 am in the process of working on a new project and discovered I have a need to use data from another database. This database is currently accessed for another application via a class library I wrote using Lightspeed. Rather than moving my new project's tables to the old database or duplicating the data in two locations, is it possible to create some sort of relationship between the two models? Thanks,
|
|
|
The models can coexist, but some care is required if you are thinking about relationships between them. For example, if your Sales model is stored in Database S, and your Logistics model in Database L, you can load entities from both models by having multiple LightSpeedContexts and multiple units of work: LightSpeedContext salesContext = new LightSpeedContext { (Of course both units of work can be active at the same time; I've shown it this way only for simplicity.) However, what you can't do is have an association across the model boundary: public class Order { The reason for this is that when LightSpeed tries to load the association, it will do so using the unit of work that the existing entity is associated with. In the example above, when you referenced someOrder.Lorry, LightSpeed would use the unit of work containing someOrder, which would be associated with Database S, so you'd get a "Lorry table not found" error. If you do require such associations you would therefore need to write them by hand, and your implementations will need to use the correct UOW/LightSpeedContext for the loading e.g. public class Order { Hope this makes sense -- please ask if you need more info. |
|