Closed
Description
Hi
Please check if this is a bug i get Exception: System.InvalidCastException : Specified cast is not valid
.
For test case these two flags must be enabled:
cache.use_second_level_cache=true
cache.use_query_cache=true
TestCase:
[Test]
public void QueryCacheWithScalarFunctionThatReturnsInt()
{
using (ISession s = OpenSession())
{
int result = s
.CreateSQLQuery("SELECT [dbo].[TestQueryCache] ()")
.SetCacheable(true)
.UniqueResult<int>();
Assert.IsNotNull(result);
}
}
Mssql scalar function create:
USE [nhibernate]
GO
/****** Object: UserDefinedFunction [dbo].[TestQueryCache] Script Date: 17.10.2017 14:11:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[TestQueryCache]
()
RETURNS INT
AS
BEGIN
RETURN DATEPART(YEAR, GETUTCDATE()) * 100 + DATEPART(MONTH, GETUTCDATE());
END
GO