abe545 / CodeOnlyStoredProcedures

A library for easily calling Stored Procedures in .NET using only code (no xml or gui).
MIT License
4 stars 3 forks source link

How do I call a mysql stored procedure? #87

Closed Rajiv-Kulkarni closed 7 years ago

Rajiv-Kulkarni commented 7 years ago

I am trying to call a mysql stored proc in a schema: IDbConnection db = _context.Database.Connection; var sp = new StoredProcedure(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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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

On Thursday, October 13, 2016, Abraham Heidebrecht notifications@github.com 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 https://github.com/abe545/CodeOnlyStoredProcedures/issues/87#issuecomment-253685412, 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 rskulka1@rockwellcollins.com rskulkar@rockwellcollins.com www.rockwellcollins.com

Rajiv-Kulkarni commented 7 years ago

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 commented 7 years ago

@Rajiv-Kulkarni I see you! 👍

abe545 commented 7 years ago

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 commented 7 years ago

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