NH requires an NH transaction for any call to the database for the NH
internals to work properly.

TransactionScope is not a substitute for an NH transaction.

On Wed, Aug 18, 2010 at 6:37 AM, Jacob Madsen <[email protected]> wrote:

> Love the feature :-)
>
> Why do you also begin a nhibernate transaction?
>
>
>
>
> On Wed, Aug 18, 2010 at 1:08 PM, Fabio Maulo <[email protected]> wrote:
>
>> using(var transactionScope = new TransactionScope())
>> using(var session = sessionFactory.OpenSession())
>> using(var tx = session.BeginTransaction())
>> {
>>    var someEntity = session.Get<SomeEntityType>(someId);
>>
>>    someEntity.Name = "bla";
>> ....
>>  transactionScope.Complete();
>>
>> NH will use autodirty check
>>
>> On Wed, Aug 18, 2010 at 7:53 AM, Jacob Madsen <[email protected]> wrote:
>>
>>> So I do not need to make an explicit Update(someEntity) call?
>>>
>>> using(var transactionScope = new TransactionScope())
>>> using(var session = sessionFactory.OpenSession())
>>> {
>>>    var someEntity = session.Get<SomeEntityType>(someId);
>>>
>>>    someEntity.Name = "bla";
>>>
>>>    session.Update(someEntity); // I want to avoid these explicit
>>> Update-calls by tracking the (dirty) entities in a session and do a single
>>> call to a "void SaveChanges()" method. The "SaveChanges" method should do
>>> the updating on the entities in a session. I still want to explicitly insert
>>> new entities with session.Save(newEntity), which I abstract and in a method
>>> called "Store".
>>>
>>>    transactionScope.Complete();
>>> }
>>>
>>> On Tue, Aug 17, 2010 at 10:30 AM, Dwarrel <[email protected]> wrote:
>>>
>>>> Yes, you would not want to use it for that reason, flush will do that
>>>> automatically. Unfortunately I do sometimes crave for a way to see
>>>> which objects are in the session. Sometimes I would want to evict all
>>>> objects of a certain type from the session cache. This if you have a
>>>> longer running session and someone else has updated the DB values.
>>>> There is no known way of evicting say all purchase info and then re-
>>>> run a query to load the relevant ones. If you don't evict them then
>>>> you get a strange mix of stale and current information as your query
>>>> result (even when having the version number available!)
>>>>
>>>> On Aug 16, 3:33 pm, Jason Dentler <[email protected]> wrote:
>>>> > Automatic dirty checking will take care of this when the session is
>>>> flushed
>>>> > (which normally happens when you commit a transaction)
>>>> >
>>>> >
>>>> >
>>>> > On Mon, Aug 16, 2010 at 4:27 AM, Jacob Madsen <[email protected]> wrote:
>>>> > > Hi all,
>>>> >
>>>> > > Is there a method to retrieve references to all entities known by a
>>>> > > session
>>>> >
>>>> > > using (var session = sessionFactory.OpenSession())
>>>> > > {
>>>> > >    var entity = session.Get<SomeType>(someId); // "entity" is now
>>>> > > known by the session
>>>> > >    ....
>>>> > >    var allKnownEntities = /* here I want to retrieve all entities
>>>> > > known/attached to a session */
>>>> > >    ....
>>>> > > }
>>>> >
>>>> > > I want to implement a "void SaveChanges()" method that will Update
>>>> all
>>>> > > modified entities known by a session.
>>>> >
>>>> > > Cheers!
>>>> >
>>>> > > --
>>>> > > 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]<nhusers%[email protected]>
>>>> <nhusers%[email protected]<nhusers%[email protected]>
>>>> ­>
>>>> > > .
>>>> > > For more options, visit this group at
>>>> > >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>>>> >
>>>> > - Show quoted text -
>>>>
>>>> --
>>>> 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]<nhusers%[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]<nhusers%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/nhusers?hl=en.
>>>
>>
>>
>>
>> --
>> Fabio Maulo
>>
>>  --
>> 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]<nhusers%[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]<nhusers%[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