Skip to content

InvokeAsync on a sproc throws at runtime #535

Closed
@kerams

Description

@kerams

Repro steps

  1. Run the script:
CREATE TABLE [dbo].[Teams](
	[Id] [nvarchar](100) NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
	[IsBotMember] [bit] NOT NULL,
 CONSTRAINT [PK_Teams] PRIMARY KEY NONCLUSTERED 
(
	[Id] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE PROCEDURE AddBotToTeam
(
    @teamId nvarchar(100),
    @teamName nvarchar(100)
)
AS
BEGIN
    SET NOCOUNT ON

    UPDATE dbo.Teams SET IsBotMember = 1 WHERE Id = @teamId

	IF @@ROWCOUNT = 0
		INSERT INTO dbo.Teams (Id, Name, IsBotMember) VALUES (@teamId, @teamName, 1)
END
GO
  1. Run the code:
let ctx = Db.GetDataContext ()
ctx.Procedures.AddBotToTeam.InvokeAsync ("", "") |> Async.RunSynchronously

Expected behavior

The stored procedure is called without errors.

Actual behavior

The stored procedure does not get called and an exception is thrown:

System.InvalidCastException: Unable to cast object of type 'Microsoft.FSharp.Control.FSharpAsync`1[FSharp.Data.Sql.Common.SqlEntity]' to type 'Microsoft.FSharp.Control.FSharpAsync`1[Microsoft.FSharp.Core.Unit]'.
   at <StartupCode$FSI_0009>.$FSI_0009.main@()

Known workarounds

Call the synchronous variant of the method.

Related information

  • Used database - Azure SQL DB
  • SQLProvider version 1.1.39

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions