I don't quite understand how your code works, but some general pointers:
The session is commonly rather short-lived (but not too short.
"unit-of-work" is common while "application-lifetime" is not typical).
If the session is in what appears to be a singleton Business object, how
are you handling multithreading?

/Oskar


2012/9/4 Jakes <[email protected]>

> Hi,
>
> I think my problem is im using the same instance all the time in my
> webapplications.
>
> Like this is my businessObject which initialize the nHibernate session in
> its constructor.
>
>         public static Business Get()
>         {
>             return _instance ?? (_instance = new Business());
>         }
>
> So when i need to use my business i do it like this.
>             IBusiness biz = Business.Get();
>
>             biz.Category.Read();
>
> Can i do this in a webservice.
>
> Regarding how im passing the data to the DTO im using linq like this,
> where WsEvent is my DTO and Event is my nhibernate object.:
>         public WsEvent[] GetServiceEvents()
>         {
>             return (from e in Business.Get().Event.Read() select new
> WsEvent {EventId = e.Id, EventName = e.Name})
>                     .ToArray();
>         }
>
> Any suggestions what to do?
>
> Regards,
> Jacob
>
>
>
>
> Den tirsdag den 28. august 2012 13.51.49 UTC+2 skrev Ricardo Peres:
>
>> You are using lazy collections/properties, right? How are you passing
>> data from your entities to the DTOs?
>> Can you post your code?
>>
>>
>>
>> On Monday, August 27, 2012 8:01:57 AM UTC+1, Jakes wrote:
>>>
>>> I have a problem using nHibernate in my webservice.
>>>
>>> Its first time i have used nHibernate in a Webservice but have used it
>>> in my ASP.NET <http://asp.net/> applications for the last 4-5 years.
>>>
>>> What i would like to do is have some of the functions in my 
>>> ASP.NET<http://asp.net/> application
>>> be available though a webservice.
>>> I have made som DataTransferObjects because i dont need all the data for
>>> the objects going though the webservice.
>>>
>>> When i try to get some data though the DAL (which works fine in the
>>> ASP.NET <http://asp.net/> application) then i get an error that the
>>> session (gues its the nHibernate session) is not initialized???
>>>
>>> Do i have to do something speciel with the nHibernate session to get it
>>> to work though a webservice that i do not need in a ASP.NET<http://asp.net/>
>>>  aplication.
>>>
>>> Hobe some one can help me.
>>>
>>> Regards,
>>> Jacob
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nhusers/-/ELLcxMq6aq4J.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to