Evtl. bug in Beta version of dotConnect for Oracle 5.35.52

Evtl. bug in Beta version of dotConnect for Oracle 5.35.52

Postby Kurt_Jegge » Mon 09 Nov 2009 18:08

Hello

I'm having the following error when I call a stored procedure from linq

Code snippet
string s = null;
db.GetAvdat(h.KategoriCd, h.SchildNr, h.StammNr, ref s);

s gets the value of the first parameter instead of the value of ref s

//StoredProcedure signature, oracle 9207

procedure get_avdat( kat_in varchar2, schild_in varchar2, stamm_nr_in varchar2, avdat_out out varchar2 )

// Generated code
// AvdatOut = ((string)(result.GetParameterValues returns the first parameter, in this case KatIn instead of the ref string AvdatOut
[Function(Name=@"TSTEUER.GET_AVDAT")]
public System.Int32 GetAvdat([Parameter(Name="KAT_IN", DbType="VARCHAR2")] string KatIn, [Parameter(Name="SCHILD_IN", DbType="VARCHAR2")] string SchildIn, [Parameter(Name="STAMM_NR_IN", DbType="VARCHAR2")] string StammNrIn, [Parameter(Name="AVDAT_OUT", DbType="VARCHAR2")] ref string AvdatOut)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), KatIn, SchildIn, StammNrIn, AvdatOut);
AvdatOut = ((string)(result.GetParameterValue(0)));
return ((System.Int32)(result.ReturnValue));
}


// This works manually changed code
[Function(Name=@"TSTEUER.GET_AVDAT")]
public System.Int32 GetAvdat([Parameter(Name="KAT_IN", DbType="VARCHAR2")] string KatIn, [Parameter(Name="SCHILD_IN", DbType="VARCHAR2")] string SchildIn, [Parameter(Name="STAMM_NR_IN", DbType="VARCHAR2")] string StammNrIn, [Parameter(Name="AVDAT_OUT", DbType="VARCHAR2")] ref string AvdatOut)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), KatIn, SchildIn, StammNrIn, AvdatOut);
AvdatOut = ((string)(result.GetParameterValue(3))); //Manually changed to ...Value(3)
return ((System.Int32)(result.ReturnValue));
}

Best regards
Kurt
Kurt_Jegge
 
Posts: 21
Joined: Wed 09 Sep 2009 10:38

Postby Shalex » Tue 10 Nov 2009 10:53

Thank you for the bug report. The fix will be available in the next build.
You can fix the problem manually in the current build: create a new template in Template Browser, set its name, select the LINQ to SQL type, make Load from existing template (with "LINQ C#"). Navigate in the template text to the implemantation of the GenerateContextMethods() method, and replace the existing template part:
Code: Select all
<#+
        int count = 0;
        foreach (LinqMethodParameter parameter in method.Parameters) {
          if (parameter.Direction != ParameterDirection.Input) {
#>
            <#= codeProvider.GetValidIdentifier(parameter.Name) #> = ((<#= codeProvider.GetNullableType(true, parameter.Type) #>)(result.GetParameterValue(<#= count #>)));
<#+
            count ++;
          }
        }
#>

with the following code:
Code: Select all
<#+
        int count = 0;
        foreach (LinqMethodParameter parameter in method.Parameters) {
          if (parameter.Direction != ParameterDirection.Input) {
#>
            <#= codeProvider.GetValidIdentifier(parameter.Name) #> = ((<#= codeProvider.GetNullableType(true, parameter.Type) #>)(result.GetParameterValue(<#= count #>)));
<#+
          }
          count++;
        }
#>

Save the new template. Then open your LINQ to SQL model in Entity Developer, Project -> Properties, and select your new template in the Templates drop-down list of the opened dialog. And now your template will be used for the code generation for your model.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle