I have a basic nHibernate that I am trying to use a formula mapping attribute on:
CREATE FUNCTION [dbo].[IsValueApprovalRequired]
(
-- Add the parameters for the function here
@ValueApprovalID BigInt
)
RETURNS Bit
AS
BEGIN
return CAST(1 as bit)
END
my class definition is pretty simple, and I am trying to map the formula to the class like so:
[Class(Table="MyTable")]
public class MyClass
{
private long _id;
/// <summary>
/// A unique identifier for the object
/// </summary>
[Id(0, Name = "ID", Column = "ValueApproval_ID")]
[Generator(1, Class = "identity")]
public override long ID
{
get
{
return _id;
}
set
{
this._id = value;
}
}
[NHibernate.Mapping.Attributes.Formula(Content = "(SELECT dbo.IsValueApprovalRequired(ID))")]
private bool _isValueApprovalRequired;
/// <summary>
/// returns if this approval is considered required.
/// </summary>
public virtual bool IsValueApprovalRequired
{
get { return _isValueApprovalRequired; }
}
}
The class is getting loaded, but the variable that is mapped to the formula is not getting populated.
Does anyone know why this is not working? I watch the sql request, and the scalar is not in the given select statement.
Thanks for your help in advance!