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`ve got a bit complex model. There are some classes: Subscriber, MobileVoiceCallService, NetworkService. MobileVoiceCallService use a Subscriber. And MobileVoiceCallService is derived from MobileNetworkServiceBase, which is derived from NetworkService. MobileVoiceCallService and Subscriber is in the assembly A, MobileNetworkServiceBase and NetworkService is in the assembly B. Here is classes specification: Assembly A (namespace A): [Table("Subscribers")]
[Table("MobileVoiceCallServices")] ..... [NoReverseAssociation] .......
Assembly B (namespace B): [Table("MobileVoiceCallServiceBases")] }
[Table("NetworkServices")] Now, a try to just create entities. The first case: [TestMethod] Assert.IsNotNull(service); } It`s OK, the test is passed. The second case: [TestMethod] Assert.IsNotNull(subscriber); MobileVoiceCallService service = new MobileVoiceCallService(); Assert.IsNotNull(service); } And now I get a KeyNotFoundException from MobileVoiceCallService constuctor! You can see, I didn`t create any unit of work, I just created a new entity. Here is the stack trace: at System.Collections.Generic.Dictionary`2.get_Item(TKey key) It is a very strange issue. I can`t reproduce it with simple example. May be you can give me some advice to solve this problem? I`m ready to give you any extra information about my model what you need. Thanks. |
|
|
I think the problem is the cross-assembly association. These aren't really supported (because it causes problems when LightSpeed tries to build its internal cache of the schema), though you can sometimes get away with it by always instantiating a derived type from the 'derived' assembly before touching any type from the 'base' assembly. In your first test, you instantiate MobileVoiceCallService, which causes LightSpeed to traverse up into Assembly B and load the base classes successfully. But it looks like the second test doesn't touch anything in B before it instantiates MVCS. Does Subscriber have an association to any type in Assembly B? You may find that you need to just create a dummy MVCS before doing anything else. You don't need to join it to any UOW -- just creating it is enough to get LightSpeed to build its cache. Not elegant, but we don't have a nice solution for this at the moment I'm afraid. |
|
|
Hi Ivan! Thank you for the answer! Yes, it`ll work fine, if I create dummy MobileVoiceCallService while starting the application. But if I touch any other entity from Assembly B first, I`ll still get the exception. Any way, solution with creating dummy MobileVoiceCallService works, thank you! |
|