none
entity framwork with mysql producure RRS feed

  • Question

  • I have been using EF with mysql, i create a procedure  pr_SMSSend`(userType INT,_mobile CHAR(11),_smsCode CHAR(6)),when i invoke it,see the code in the following

     var param = new System.Data.EntityClient.EntityParameter("userType", System.Data.DbType.Int32);
                var param2 = new System.Data.EntityClient.EntityParameter("_mobile", System.Data.DbType.String);
                var param3 = new System.Data.EntityClient.EntityParameter("_smsCode", System.Data.DbType.String);
                param.Value = userType;
                param2.Value = mobile;
                param3.Value = code;

                return ExecuteFunction<int>("SMSSend", new[] { param, param2, param3 });

    it return error message:

    Parameter name" _mobile" is not valid. Effective parameter names must begin with a letter, and can only contain letters, numbers and underscores. Parameter name: parameterName.

    Thanks

    Tuesday, June 19, 2012 10:27 AM

Answers

  • In EDMX definition, usually replace those leading underscore with specific prefix. function _my_func => f_my_func; parameter _my_par => p_my_par

    So we should avoid this kind of naming when we are using with Entity Framework, so far.

    For return value, you can set return result set when you import the function via EDMX.

    Wednesday, June 20, 2012 3:05 AM

All replies

  • Have you try with other alternative way; Add SP function in EDMX and call it as a normal function.

    using (Entities e = new Entities()) {
           e.SPFunction(para1,para2,para3);
    }


    Tuesday, June 19, 2012 3:39 PM
  • Thank you for your reply, i remove the '_'  from the '_mobile' and '_smsCode',it run well,but i want know why i can't use _ in parameter, it valid use _ in mysql produre.

    pr_SMSSend`(userType INT,_mobile CHAR(11),_smsCode CHAR(6)) return int, i use vs2008, it not support function return int

    Wednesday, June 20, 2012 1:40 AM
  • In EDMX definition, usually replace those leading underscore with specific prefix. function _my_func => f_my_func; parameter _my_par => p_my_par

    So we should avoid this kind of naming when we are using with Entity Framework, so far.

    For return value, you can set return result set when you import the function via EDMX.

    Wednesday, June 20, 2012 3:05 AM