Sure, here is my load method:
Code:
Dim Criteria As NHibernate.ICriteria
Criteria = MyBase.Session.CreateCriteria(GetType(GMBPDefinition.Classes.MatchStrings.BaseMatchString))
Criteria.Add(NHibernate.Expression.Expression.Eq("Id", Id))
Dim list As IList(Of GMBPDefinition.Interfaces.IMatchString) = Criteria.List(Of GMBPDefinition.Interfaces.IMatchString)()
If list.Count > 0 Then
Return list(0)
Else
Return Nothing
End If
Now you can see it is not useing the Session.Load() method.
I don't know which version of the class it will be (because that is controlled by the disciminator) so I can't pass in an object to load method.
I have tried variations, such as :
Code:
'Dim result As GMBPDefinition.Interfaces.IMatchString
''result = New GMBPDefinition.Classes.MatchStrings.BaseMatchString()
'result = MyBase.Session.Load(Of GMBPDefinition.Classes.MatchStrings.BaseMatchString)(Id)
''MyBase.Session.Load(result, Id)
'Return result
It did not like the passing of a Base Match String, and when it did load, the object could not be saved again as it was some NHibernate object that had not been initialised.
It is working, but there must be a better way to do it.
Thanks