This question is locked. New answers and comments are not allowed.
I have a theoretical question. I'm currently using nHIbernate and the nHibernate session is tied to the HttpContext.Current. My problem is, when I create a new thread, HttpContext.Current is becoming null and my session is disappearing. I could probably try to change my session management to create a new session HttpContext is null and then save the session somewhere else, but I'm straying from my question.
I'm curious if I have an object that's been loaded while the HttpContext.Current is not null, but then becomes null, can I continue to use the object?
Can I do something like the following without an exception. Because nHibernate is now giving me a "no session" error.
If so, I may ditch nHibernate and give OpenAccess a try.
Thanks,
Eric
I'm curious if I have an object that's been loaded while the HttpContext.Current is not null, but then becomes null, can I continue to use the object?
Can I do something like the following without an exception. Because nHibernate is now giving me a "no session" error.
public
class
MyClass() {
private
Product _product;
public
MyClass(Product product) {
_product = product;
}
public
DoSomething() {
Thread thread =
new
Thread(DoSomethingAsync);
thread.IsBackground =
true
;
thread.Start();
}
private
DoSomethingAsync() {
// HttpContext.Current will be null here
Logger.Info(product.Category.Name);
}
}
// Can I call this line elsewhere in my application?
new
MyClass(product).DoSomething();
If so, I may ditch nHibernate and give OpenAccess a try.
Thanks,
Eric