This is a .Net project using brail pages and ActiveRecord/NHibernate

I have been calling a function with a 'for x to n' statement. But I'd
like to make it transactional. I'm seeing examples for other RAILS
implementations of ActiveRecord, but I'm not sure about how to do it
here.

Currently I'm working it like this:
For Number As Integer = CitationStartNumber To CitationEndNumber.Value
    If CitationAdd(CitationType, Number, District) Then CitationTotal
+= 1
Next

...
Private Function CitationAdd(ByVal CitationType As String, ByVal
Number As Integer, ByVal District As District) As Boolean
            Dim Criteria As DetachedCriteria = DetachedCriteria.For(Of
Citation)()
            Criteria.Add(Expression.Eq("CitationType", CitationType))
            Criteria.Add(Expression.Eq("CitationNumber", Number))

            Dim NewCitation As Citation
            If Not Citation.Exists(Criteria) Then
                Select Case CitationType
                    Case "FA"
                        NewCitation = New FACitation(Number)
                    Case "FB"
                        NewCitation = New FBCitation(Number)
                    Case Else
                        NewCitation = New FCCitation(Number)
                End Select
                NewCitation.District = District
                NewCitation.UpdatedBy = Page.SecurityIdentity.Name
                NewCitation.UpdatedOn = DateTime.Now
                NewCitation.Create()
            Else
                NewCitation = Citation.FindOne(Criteria)
                NewCitation.District = District
                NewCitation.UpdatedBy = Page.SecurityIdentity.Name
                NewCitation.UpdatedOn = DateTime.Now
                NewCitation.Update()
            End If
            Return True
        End Function



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

Reply via email to