Rhino Tools set the flush mode to commit, instead of auto.This is why you
are seeing that.

On Mon, Mar 23, 2009 at 11:47 AM, Junior <[email protected]>wrote:

>
> Hi all,
>
> I am trying to understand session management in Rhino Commons
> Repository<T> and UnitOfWork, I have tried my best at understanding
> the source code, but feel I am misunderstanding some concepts. Briefly
> my problem is this:
>
> I save an entity using Repository<T>:
> Repository<Car>.Save(new Car{Id = 1});
>
> I can then retrieve the car like so:
> Car car = Repository<Car>.Get(1);
>
> Thanks to the Session cache, the car is retrieved without having to
> flush the session / commit a tx / write to the database.
> However when I then try to query Car using NHibernate Linq provider:
>
> IQueryable<Car> cars = (from car in UnitOfWork.CurrentSession.Linq<Car>
> ()
> select car);
>
> I get nothing, unless I explicity flush the session / commit a tx
> after saving the car. I understand that UoW requires you to commit the
> transaction before it writes the changes to the db. However as I also
> understand from looking at the Rhino Commons source code and the
> NHibernate Contrib code, I should not have to do this (flush the
> changes) as the Linq provider will use the same session and thus
> should be able to 'see' the session cache:
>
> NHRepsoitory uses this:
>
> protected virtual ISession Session
> {
>    get { return UnitOfWork.CurrentSession; }
> }
>
> And NHibernateExtensions Linq method is also passed
> UnitOfWork.CurrentSession. So my question is this - is this the
> expected behaviour (having to flush a repository save before using
> Linq to NHibernate)? If so, why? Or am I misunderstanding something
> and need to take a deeper look into the code?
>
> Many thanks for any help!
>
> James
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" 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/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to