Bug #81530 EDMX generate wrong stored procedure call
Submitted: 22 May 2016 10:15 Modified: 23 May 2016 12:46
Reporter: ZOKIAD ZOKIAD Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.8 OS:Windows (10 64bit)
Assigned to: CPU Architecture:Any

[22 May 2016 10:15] ZOKIAD ZOKIAD
Description:
In visual studio 2015, when generate a "ADO.NET Entity Data Model", the call of stored procedure is wrong: parameter name is wrong

How to repeat:
1/ Database, create a stored procedure:

CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `TestProc`(
	_Param1 BIGINT,
	_Param2 BIGINT,
	_Param3 BIGINT,
	_Param4 BIGINT,
	_Param5 BIGINT
)
BEGIN

END

2/ In Visual Studio 2015:
- Add New Item -> ADO.NET Entity DataModel 
- Select a mysql database and select at least the stored procedure.
During the generation of model, there are warning messages.

3/ Check generate code (*.context.cs):

        public virtual int TestProc(Nullable<long> p_Param1, Nullable<long> p_Param2, Nullable<long> p_Param3, Nullable<long> p_Param4, Nullable<long> p_Param5)
        {
            var p_Param1Parameter = p_Param1.HasValue ?
                new ObjectParameter("p_Param1", p_Param1) :
                new ObjectParameter("p_Param1", typeof(long));
    
            var p_Param2Parameter = p_Param2.HasValue ?
                new ObjectParameter("p_Param2", p_Param2) :
                new ObjectParameter("p_Param2", typeof(long));
    
            var p_Param3Parameter = p_Param3.HasValue ?
                new ObjectParameter("p_Param3", p_Param3) :
                new ObjectParameter("p_Param3", typeof(long));
    
            var p_Param4Parameter = p_Param4.HasValue ?
                new ObjectParameter("p_Param4", p_Param4) :
                new ObjectParameter("p_Param4", typeof(long));
    
            var p_Param5Parameter = p_Param5.HasValue ?
                new ObjectParameter("p_Param5", p_Param5) :
                new ObjectParameter("p_Param5", typeof(long));
    
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("TestProc", p_Param1Parameter, p_Param2Parameter, p_Param3Parameter, p_Param4Parameter, p_Param5Parameter);
        }

For each parameter name, a wrong name is generated ("p_Param1" instead of "_Param1).

Suggested fix:
Remove p before the parameter name.

            var p_Param1Parameter = p_Param1.HasValue ?
                new ObjectParameter("_Param1", p_Param1) :
                new ObjectParameter("_Param1", typeof(long));
[23 May 2016 12:46] Chiranjeevi Battula
Hello ZOKIAD ZOKIAD,

Thank you for your report and test case.
Verified this behavior on Visual Studio 2013 (C#.Net) and Connector/NET 6.9.8 version.

Thanks,
Chiranjeevi.
[23 May 2016 12:48] Chiranjeevi Battula
public virtual int TestProc(Nullable<long> p_Param1, Nullable<long> p_Param2, Nullable<long> p_Param3, Nullable<long> p_Param4, Nullable<long> p_Param5)
        {
            var p_Param1Parameter = p_Param1.HasValue ?
                new ObjectParameter("p_Param1", p_Param1) :
                new ObjectParameter("p_Param1", typeof(long));
    
            var p_Param2Parameter = p_Param2.HasValue ?
                new ObjectParameter("p_Param2", p_Param2) :
                new ObjectParameter("p_Param2", typeof(long));
    
            var p_Param3Parameter = p_Param3.HasValue ?
                new ObjectParameter("p_Param3", p_Param3) :
                new ObjectParameter("p_Param3", typeof(long));
    
            var p_Param4Parameter = p_Param4.HasValue ?
                new ObjectParameter("p_Param4", p_Param4) :
                new ObjectParameter("p_Param4", typeof(long));
    
            var p_Param5Parameter = p_Param5.HasValue ?
                new ObjectParameter("p_Param5", p_Param5) :
                new ObjectParameter("p_Param5", typeof(long));
    
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("TestProc", p_Param1Parameter, p_Param2Parameter, p_Param3Parameter, p_Param4Parameter, p_Param5Parameter);
        }