Hi,
Got a weird nHibernate problem. I have a table called AssetRule which is being mapped with the following code:
Public Class AssetRuleMap
Inherits FluentNHibernate.Mapping.ClassMap(Of AssetRule)
Public Sub New()
Id(Function(x) x.Id)
Map(Function(x) x.PageType).CustomType(Of PageType)()
Map(Function(x) x.Path)
Map(Function(x) x.MaxAssets)
Map(Function(x) x.RegionNumber)
Map(Function(x) x.RequiredRowType).CustomType(Of RowType)()
End Sub
End Class
Which all works fine, except for the Path element. Path is a String - all the other values in the object are integers and so it creates an nVarchar field in the data table.
If I go into my table and put some text into this field, and then run my application and get a list of all the rows in the table using nHibernate like this:
Public Function GetAssetRules() As System.Collections.Generic.IList(Of DataTransferObjects.AssetRule) Implements IRegionManager.GetAssetRules
Dim session As ISession = NHibernateSessionManagerStore.Instance.GetSession()
Dim result As IList(Of DataTransferObjects.AssetRule)
result = session.CreateCriteria(Of DataTransferObjects.AssetRule)() _
.List(Of DataTransferObjects.AssetRule)()
Return result
End Function
It returns all the data successfully, except that the Path values are set to Nothing whatever the value in the database. And when I go back and look at the data - voila, all my Path fields have been set to null.
What on earth is causing this to happen?
Cheers, Matt