Sure have a look here: http://www.pastie.org/617135

then you can use it like:

Dim ctx As New DataContext()
Dim stockitem As Stock.Stmaster
stockitem = ctx.RandomOne(Of Stock.Stmaster)()
stockitem = ctx.Load(Of Stock.Stmaster)(17)

and saving like this:

_ctx.BeginSave()

_ctx.Save(_jobcard)

For Each d As Jobdetails In _jobcard.Details
    _ctx.Save(d)
Next

_ctx.EndSave()

there is also criteria and query support,etc. The main idea is to have
all database access go through the datacontext class. We normally have
one context per form.
You probably won't be able to use it out of the box but might give you
a few ideas :-)

Hope this helps.

~Gerdus

On Tue, Sep 15, 2009 at 1:47 AM, Troy Schmidt <[email protected]> wrote:
>
> Care to share this wrapper methodology?  I have been searching for a
> whole day to try and find out about nhibernate session management and
> how I can incorporate that into Castle, but not finding much info at
> all.
>
> On Sep 9, 7:03 am, Gerdus van Zyl <[email protected]> wrote:
>> I used to use a SessionScope(FlushAction.Never) and call flush on Save
>> and just do nothing on Cancel. If you have relatively simple forms and
>> only a few forms open at once this works quite well. Having long lived
>> sessions are however not recommended. Also sessionscopes use a stack
>> based model so you can't associated a form with a specific session.
>>
>> I however have thrown out sessionscopes in my current architecture for
>> direcly managing nhibernate sessions (using AR for mapping/conf only)
>> via a wrapper for more control in my winforms app.
>>
>> On Wed, Sep 9, 2009 at 11:38 AM, Catalin DICU<[email protected]> wrote:
>>
>> > Hello,
>>
>> > I have a modal form witch lets the user modify a record. I'd like to
>> > be able to commit changes when the form is closed with "OK" button and
>> > rollback when the form is closed with "Cancel" button.
>>
>> > How would I do that ? Create a transaction scope in the form
>> > constructor and dispose it when the form closes ?
>>
>> > What happends if I already have a session ?
>>
>> > And what SessionScope.Flush() is supposed to do  ? It seems like the
>> > canges are send to the database only on Dispose()
>>
>> > Thanks
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to