GithubHelp home page GithubHelp logo

Comments (23)

ErikEJ avatar ErikEJ commented on September 20, 2024 1

I only recently implemented support for stored procedure discovery with a .dacpac, so I am hoping this is just a feature gap. If it is urgent for you I accept sponsorships! 😄

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024 1

@ErikEJ Works like a charm 😄

Again, thank you!

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

Correct, that is not supported, but can you provide a proper repro, you should see a message like this in the outptu window, not an error like above:

Unable to scaffold FUNCTION 'dbo.FuncWithTvpParameter' as it has TVP parameters.

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Thanks for quick reply!
I'll try to setup a repro soon and link it to you.

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Out of curiosity, will TVP be implemented in the future?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

Out of curiosity, will TVP be implemented in the future?

You can map a tvp returning function today.

But how would you manually code a call using a TVP parameter today (using ADO.NET fo example) ?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

@HAK-Logos Sorry! Actually, the error above is from Functions with tvp parameters - as far as I can see, stored procedure tvp parameters should be supported (as DataTable), but there could be a regression and I am lacking a good sample for my regression test!

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Good, then I'm not going crazy. I was wondering why you were referring to Functions :-)

So it is possible to include TVP in Stored Procedures, but I'm getting the above error.
Is there anything I can do to help you locate the issue?

Just for reference, this is the code where it throws the exception:
https://github.com/ErikEJ/EFCorePowerTools/blob/master/src/Core/RevEng.Core.60/Routines/Extensions/SqlServerSqlTypeExtensions.cs
image

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

I can see that you should NOT be using "legacyResultSetDiscovery" in order for the parameters to be discovered.

For help, please provide a runnable set of SQL scripts that creates the required objects and I can step through the code.

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Here's a script for the user defined type:

CREATE TYPE [dbo].[IntegerList] AS TABLE(
[I] INT NOT NULL,
PRIMARY KEY CLUSTERED ([I] ASC)
);

And here's a sproc:

CREATE PROCEDURE [dbo].[SomeStoredProcedure]
@SomeParameter1 BIGINT,
@SomeParameterList1 [dbo].[IntegerList] READONLY
AS
BEGIN
SET XACT_ABORT ON
SELECT 1
END

Is that enough?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

@HAK-Logos Yes! And does that cause the error you listed above?

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Yes, it should

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

@HAK-Logos But it does not! Please provide a repro that actually causes the error you reported above.

public virtual async Task<List<SomeStoredProcedureResult>> SomeStoredProcedureAsync(long? SomeParameter1, DataTable SomeParameterList1, OutputParameter<int> returnValue = null, CancellationToken cancellationToken = default)
        {
            var parameterreturnValue = new SqlParameter
            {
                ParameterName = "returnValue",
                Direction = System.Data.ParameterDirection.Output,
                SqlDbType = System.Data.SqlDbType.Int,
            };

            var sqlParameters = new []
            {
                new SqlParameter
                {
                    ParameterName = "SomeParameter1",
                    Value = SomeParameter1 ?? Convert.DBNull,
                    SqlDbType = System.Data.SqlDbType.BigInt,
                },
                new SqlParameter
                {
                    ParameterName = "SomeParameterList1",
                    Value = SomeParameterList1 ?? Convert.DBNull,
                    SqlDbType = System.Data.SqlDbType.Structured,
                    TypeName = "[dbo].[IntegerList]",
                },
                parameterreturnValue,
            };
            var _ = await _context.SqlQueryAsync<SomeStoredProcedureResult>("EXEC @returnValue = [dbo].[SomeStoredProcedure] @SomeParameter1 = @SomeParameter1, @SomeParameterList1 = @SomeParameterList1", sqlParameters, cancellationToken);

            returnValue?.SetValue(parameterreturnValue.Value);

            return _;
        }

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Intriguing.. Let me setup a project that replicates the issue and link it to you. Unfortunately I can't link the current project to you. It might take some time, but I will get back to you.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

Ah, I missed this "Is a SQL Server .dacpac used: yes" 😄

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

Potentially not supported (yet) with a .dacpac

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Oh fair enough, that's alright 😄

Sorry, had to remove my previous comment. Uploaded the wrong .zip file.

Here's the right one.

EFCPT.zip

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Potentially not supported (yet) with a .dacpac

So only potentially, that's better than "not supported" 😄

I hope it's not that big of a deal to make it work, otherwise I have to put this branch on hold for now.

We are changing some "old" code from passing comma separated strings to SQL, to now use TVP. Converting that string to something edible in SQL is kind of performance heavy, when we pass around 10k values.. So it would be nice to have this working 🙂

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

Workaround would be to publish the .dacpac a generate code from the published database

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Workaround would be to publish the .dacpac a generate code from the published database

Hmm.. That is a solution, but I just don't see it being practical in a live environment, fully integrated with CI/CD.

Do you already know, what is required for TVP to be compatible with .dacpac? Or if you're planning to implement it in the near future? 🙂

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

I understand 😉 I will get back to you sooner or later!

Anyways, thanks for the help for now 👍

from efcorepowertools.

ErikEJ avatar ErikEJ commented on September 20, 2024

I implemented a fix for this in the latest daily build, would be grateful if you could try it out.

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship

from efcorepowertools.

HAK-Logos avatar HAK-Logos commented on September 20, 2024

Well that was fast 😄

I appreciate it! And ofc. I'll as a minimum review your tool.

Have a great evening 🙂

from efcorepowertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.