none
Bug in MSDataSetGenerator? Overloaded TableAdapter Update method declared with ref parameters, but called without ref in generated code RRS feed

  • Question

  • (Sorry for the crossposting. This question is related to both dataset and tableadapters.. )


    I have a problem that I can't seem to find the answer to in articles or forums.

    The situation:

    I have an UpdateCommand element with  some parameters which are AllowDbNull and InputOutput in direction.

    They are generated correctly as a nullable ref (for instance ref nullable<int> for an int)  in the *.Designer.cs class after chosing "run custom tool", which runs the standard MSDataSetGenerator.

    The generator then creates TWO update methods. One with all the parameters expected, declared correctly, and one overloaded method with one less parameter, but still declared correctly. This is only done for the datatables that don't have autoincrement on the primary key.  The problem is that the overload with one less parameter calls the one with all the parameters, but WITHOUT ADDING REF. So after running the custom tool the project doesnt build.



    Is this a bug in Visual Studio 2008 / MsDataSetGenerator (tried with and without SP1), or am i declaring something wrong in the xsd file? (it is being edited by a tool i created to the code you see in the example).


    Some code excerpts to make it easier to understand: 

    UpdateCommand xsd element:

     
    <UpdateCommand> 
                      <DbCommand CommandType="StoredProcedure" ModifiedByUser="false">  
                        <CommandText>Model.UpdateBaseEntity_Generated</CommandText> 
                        <Parameters> 
     
    <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="ReturnValue" ParameterName="@RETURN_VALUE" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumnNullMapping="false" SourceVersion="Current" /> 
                            
    <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="InputOutput" ParameterName="@Model_Id" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="Model_Id" SourceColumnNullMapping="false" SourceVersion="Current" /> 
     
    <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="InputOutput" ParameterName="@ManModel_Id" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="ManModel_Id" SourceColumnNullMapping="false" SourceVersion="Current" /> 
                            
     <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Model_Id" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="Model_Id" SourceColumnNullMapping="false" SourceVersion="Original" /> 
     
    <Parameter AllowDbNull="true" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_ManModel_Id" Precision="10" ProviderType="Int" Scale="0" Size="4" SourceColumn="ManModel_Id" SourceColumnNullMapping="false" SourceVersion="Original" /> 
                          
                        </Parameters> 
                      </DbCommand> 
                    </UpdateCommand> 




    The original update method with all parameters
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]  
    [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]  
    [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, true)]  
       
    public virtual int Update(  
        ref global::System.Nullable<int> Model_Id,   
        ref global::System.Nullable<int> ManModel_Id,   
        global::System.Nullable<int> Original_Model_Id,   
        global::System.Nullable<int> Original_ManModel_Id )   
     
    {  
    //CODE REMOVED , not important for this example  
    }  
     


    The overloaded method with one less parameter

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]  
    [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")]  
    [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, true)]  
     
    public virtual int Update(  
    ref global::System.Nullable<int> ManModel_Id,    
    global::System.Nullable<int> Original_Model_Id,   
    global::System.Nullable<int> Original_ManModel_Id)   
    {  
    //WHERE IS THE REF ON THE FIRST TWO PARAMETERS IN THIS METHOD CALL?  
    return this.Update(Original_Model_Id, ManModel_Id, Original_Model_Id, Original_ManModel_Id);  
    }  
     
     




           

    Thursday, December 18, 2008 9:19 AM