Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems that impossible to call SP which has output sql_variant parameters #41

Closed
guffy1234 opened this issue Jun 2, 2020 · 3 comments

Comments

@guffy1234
Copy link

As an example, it's impossible to call systems stored procedure to get range from a sequence:

        this.LoadStoredProc("sys.sp_sequence_get_range")
            .AddParam("sequence_name", sequence)
            .AddParam("range_size", range_size)
            .AddParam("range_first_value", out IOutParam<int> range_first_value)
            .AddParam("range_last_value", out IOutParam<int> range_last_value)
            .ExecNonQuery();
@verdie-g
Copy link
Owner

verdie-g commented Jun 2, 2020

IStoredProcBuilder AddParam(DbParameter parameter);

This overload accepts a DbParameter so can you pass a SqlParameter with a SqlDbType.Variant.

@guffy1234
Copy link
Author

guffy1234 commented Jun 3, 2020

yes, this code is workable:

var firstValueInRange = new SqlParameter("@range_first_value", SqlDbType.Variant)
            {
                Direction = ParameterDirection.Output
            };
            var lastValueInRange = new SqlParameter("@range_last_value", SqlDbType.Variant)
            {
                Direction = ParameterDirection.Output
            };
            await this.LoadStoredProc("sys.sp_sequence_get_range")
                .AddParam("@sequence_name", name)
                .AddParam("@range_size", range_size)
                .AddParam(firstValueInRange)
                .AddParam(lastValueInRange)
                .ExecNonQueryAsync();
            return new Tuple<int, int>((int)firstValueInRange.Value, (int)lastValueInRange.Value);

but probably it would be nice to find some way how to handle the case in a more elegant way.
convert to expected type when it possible. or allow to use IOutParam < object >

@verdie-g
Copy link
Owner

verdie-g commented Jun 5, 2020

There is no plan to add database specific extension.

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

No branches or pull requests

2 participants