Dapper or MySql not finding stored procedures that contain a full stop “.”

情到浓时终转凉″ 提交于 2019-12-12 12:48:52

问题


I've got a simple c# console that uses the Dapper ORM to make a call to a local MySql database in order to execute a stored procedure called users.UserCreate.

However, when running the query I get an exception saying

Procedure or function 'UserCreate' cannot be found in database 'users'

But users isn't the database local_db is.

Here an example use:

public virtual Task CreateAsync(User user)
{
        using (var con = new MySqlConnection(_dbConn))
            return con.ExecuteAsync("users.UserCreate", user, commandType: CommandType.StoredProcedure);
}

_dbConn contains the connection string, also stating the name of the database as local_db.

This is what the stored procedure looks like:

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `users.UserCreate`(IN `@UserId` VARCHAR(128), IN `@UserName` VARCHAR(255), IN `@PasswordHash` LONGTEXT, IN `@SecurityStamp` LONGTEXT)
    NO SQL
INSERT INTO Users
(Id, UserName, PasswordHash, SecurityStamp, EmailConfirmed, PhoneNumberConfirmed, TwoFactorEnabled, LockoutEnabled, DateCreated, DateUpdated, IsDeleted)
VALUES
(@UserId, @UserName, @PasswordHash, @SecurityStamp, 0, 0, 0, 0, CURRENT_DATE, CURRENT_DATE, 0)$$
DELIMITER ;

Is the problem something to do with MySql or Dapper? I use a similar naming convention for stored procedures in SQL Server, also using Dapper, and haven't had this problem before.

I have tried:

  • Using "local_db.users.UserCreate"
  • Using "local_db.UserCreate"
  • Using "UserCreate"

Any ideas?


回答1:


Well, turns out conversion from using SQL to MySQL has been full of learning curves in terms of MySQL's (in)capabilities. To get around the schema naming conventions using full-stops/periods (".") I've just replaced it with an underscore instead.

For anyone else facing the same dilemma, use underscores, you'll save yourself hours of headaches in the long run!



来源:https://stackoverflow.com/questions/42007894/dapper-or-mysql-not-finding-stored-procedures-that-contain-a-full-stop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!