Skip to content

Paramter Type is not right. #29

Description

@jonantoine

I have a very simple example to demonstrate this issue.

I have a Table Valued Function:

CREATE FUNCTION [dbo].[TestTVF]
(	
    @param1 varchar(max)
)
RETURNS TABLE 
AS
RETURN 
(
    SELECT 1 as Id, 'Test' as [Name]
)

And I have the DbFunction

[DbFunction("DB", "TestTVF")]
public IQueryable<TestTvfResult> TestTVF([ParameterType(StoreType = "varchar(max)")] string param1)
{
    var p1 = param1 != null ?
        new ObjectParameter("param1", param1) :
        new ObjectParameter("param1", typeof(string));

    return ((IObjectContextAdapter)this).ObjectContext.
    CreateQuery<TestTvfResult>("[DB].[TestTVF](@param1)", p1);
}

But when I use the function the sql generate is this:

exec sp_executesql N'SELECT 
1 AS [C1], 
[Extent1].[Id] AS [Id], 
[Extent1].[Name] AS [Name]
FROM [dbo].[TestTVF](@param1) AS [Extent1]',N'@param1 nvarchar(4000)',@param1=N'test'

Expected: use varchar(max) and not nvarchar(4000)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions