I have the following mapping defined using FluentMapping
public class RuleMap : ClassMap<Rule>
{
public RuleMap()
{
Table("NEW");
Id(x => x.Id, "Id").Not.Nullable();
Map(x => x.SenderId, "SenderId").Nullable();
}
}
for the next class
public class Rule
{
public virtual int Id { get; set; }
public virtual int? SenderId { get; set; }
}
My table in the database is defined as
USE [Test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[NEW](
[Id] [int] NOT NULL,
[SenderId] [int] NULL,
CONSTRAINT [PK_NEW] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
and has one record with
Id | SenderId
1 | `NULL`
Now when I load all Rules through my SessionFactory
var rules = sessionFactory.QueryOvery<Rule>.List();
the list contains 1 element (how good it is), but the property SenderIdis 0 and not NULL , as I expected.
So what am I doing wrong here?
Using NHibernate 3.1 and FluentNHibernate 1.2.
Jehof source
share