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 guys, Pretty minor issue, probably due to the way I'm implementing Lightspeed at the moment :) I've got the following set up inside my configuration file: <lightSpeedContexts default="Development"> As you can see, I've specified the default context using the "default" attribute. I've written some unit tests and this works fine upon test setup (via LightspeedContext.Default the connection string is present), however during testing I get a failed test inside my repository due to the connection string being null. Now, I'm using a dependency injection tool to create my repositories, namely Autofac. This basically creates a SimpleUnitOfWorkScope<T> for my repository using the default constructor and automatically passes it through to my repository constructor (all working nicely). (Hold in there... I'm getting to the problem :)) The problem is that the default SimpleUnitOfWorkScope<T> constructor is generating an incorrect LightspeedContext - this is where the null connection string is coming from. I would have expected it to use the default lightspeed context here? NB I'm using LS3 Beta Is this something that I am doing wrong, or is it perhaps the ConnectionStrategy causing this (a bug perhaps?)? If this WAS a bug and has now been fixed then am I able to get the new LS3Beta? I've got the professional package therefore I don't think it's available under the store yet? Thanks! PS: An another note, this message box editor doesn't seem to work in Chrome? Firefox is ok though :) |
|
|
Hang on, SimpleUnitOfWorkScope<T> doesn't *have* a default constructor. Furthermore, the constructor it does have takes a LightSpeedContext<T> instance -- so the constructor doesn't "generate" a LightSpeedContext, it just gets one passed to it. My guess would therefore be that Autofac is newing up a blank LightSpeedContext and passing that to the scope constructor. Note that LightSpeedContext.Default is *not* the same as new LightSpeedContext<T>() so checking that the connection string is correct in LightSpeedContext.Default doesn't prove anything. * LightSpeedContext.Default reads the default settings from the configuration file. (If there's only one <add> element it uses that, otherwise it uses the lightSpeedContexts default="..." attribute.) * new LightSpeedContext() creates a blank context. * new LightSpeedContext(configurationName) reads the specified configuration from the configuration file. I therefore suspect you need to tell Autofac to call the overloaded constructor: new LightSpeedContext<T>("Development"). (NOTE: Do NOT tell Autofac to use LightSpeedContext.Default. LightSpeedContext.Default is NOT a LightSpeedContext<T> -- only a LightSpeedContext -- and therefore cannot be passed to the SimpleUnitOfWorkScope constructor.) |
|
|
Hi Ivan, Thanks for that; you're right - I had Autofac passing a LightSpeedContext<T> (created using the default constructor) to the SimpleUnitOfWorkScope<T> constructor. I wasn't aware that the default constructor did not populate itself from the default context so thanks for clearing that up for me - off to fix it all up now! Thanks again! |
|
|
Hi Paul, Just as an FYI, I've updated the editor control for community server so if you post in Chrome now it should work a charm :-) You may need to hold SHIFT + click refresh for it to work as you may have old JavaScript files floating around. - JD |
|