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

How do I call a mysql stored procedure? #87

Closed
Rajiv-Kulkarni opened this issue Oct 5, 2016 · 7 comments
Closed

How do I call a mysql stored procedure? #87

Rajiv-Kulkarni opened this issue Oct 5, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@Rajiv-Kulkarni
Copy link

I am trying to call a mysql stored proc in a schema:
IDbConnection db = _context.Database.Connection;
var sp = new StoredProcedure<vw_employees>(CommonHelper.GetDatabaseName(), ".sp_get_list_of_all_users();");
var allUsers = sp.Execute(db);

The sp.Execute() call fails with this error:
[MySqlException (0x80004005): Procedure or function '[' cannot be found in database '[bidmaster_dev]'.]

where schema name bidmaster_dev is returned by the call CommonHelper.GetDatabaseName(). Not sure why it is appending square brackets the sql server query style. How can I make it MySQL aware? Thanks.

@abe545 abe545 added the bug label Oct 12, 2016
@abe545 abe545 added this to the 2.3.0 milestone Oct 12, 2016
@abe545 abe545 self-assigned this Oct 12, 2016
@abe545
Copy link
Owner

abe545 commented Oct 12, 2016

Sorry for the late response, I forgot that you had asked this question!
It is not currently configurable. However, I will add an option tonight to disable this behavior, and publish a new pre-release to nuget.

@abe545
Copy link
Owner

abe545 commented Oct 14, 2016

@Rajiv-Kulkarni - I've fixed this in the latest preview release - https://www.nuget.org/packages/CodeOnlyStoredProcedures/2.3.0-pre05

You can set it up to use the backticks easily by doing this before making any stored procedure calls:
GlobalSettings.Instance.SetObjectQuoteStyle(ObjectQuoteStyle.BackTick);

@Rajiv-Kulkarni
Copy link
Author

Thanks. I will give it a try and let you know.

On Thursday, October 13, 2016, Abraham Heidebrecht [email protected]
wrote:

Hi, so, I've fixed this in the latest preview release -
https://www.nuget.org/packages/CodeOnlyStoredProcedures/2.3.0-pre05

You can set it up to use the backticks easily by doing this before making
any stored procedure calls:
GlobalSettings.Instance.SetObjectQuoteStyle(ObjectQuoteStyle.BackTick);


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#87 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMXMKsReLQAQmKpQn88uJPy1H9TPIXDEks5qztpkgaJpZM4KOVMM
.

Rajeev S Kulkarni / Sr. Software Engineer / Common Technologies Tools
Team (CT3)
MS 120-123, 350 Collins Rd NE, Cedar Rapids, IA
Phone: (319)263-4256 / Mobile: (563)508-5301
[email protected] [email protected]
www.rockwellcollins.com

@Rajiv-Kulkarni
Copy link
Author

I installed the 2.3.0-pre05 and tried to use it this way:
IDbConnection db = _context.Database.Connection;
GlobalSettings.Instance.SetObjectQuoteStyle(ObjectQuoteStyle.BackTick);
var sp = new StoredProcedure(CommonHelper.GetDatabaseName(), ".sp_get_list_of_all_users();");
var allUsers = sp.Execute(db);

Is that correct? Now I am getting error on the 2nd and the 4th line.
'GlobalSettings' is inaccessible due to its protection level
Cannot assign void to an implicitly-typed variable

Could you let me know how to use it? Thanks.

@mevans845
Copy link

@Rajiv-Kulkarni I see you! 👍

@abe545
Copy link
Owner

abe545 commented Oct 14, 2016

Oops... I can't believe I did that. It should be exposed as a static method on StoredProcedure... Sorry! It should be fixed tonight.

@abe545
Copy link
Owner

abe545 commented Oct 15, 2016

Okay, sorry about that. It should be useable now with the following:
StoredProcedure.SetObjectQuoteStyle(ObjectQuoteStyle.Backtick);

@abe545 abe545 closed this as completed Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants