none
DBML file isn't generating code for my stored procedure object RRS feed

  • Question

  • I"m dragging a stored procedure onto my dbml file but for some reason, vs.net isn't generating any of the necessary code in my code behind files.  For example, my stored procedure returns about 10 fields of data, so my dbml's xml data should have 10 "Column" elements, but instead, my xml looks like this:

    <Function Name="dbo.MyProc" Method="ASTZ_MyProc">
      <Parameter Name="SUB_PROJECT_NO" Parameter="sUB_PROJECT_NO" Type="System.String" DbType="VarChar(8)" />
      <Return Type="System.Int32" />
     </Function>
    

    In addition, my dbml's designer.cs file isn't creating a partial class.  It only creates the following:

    [Function(Name="dbo.MyProc")]
    		public int MyProc([Parameter(Name="SUB_PROJECT_NO", DbType="VarChar(8)")] string sUB_PROJECT_NO)
    		{
    			IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), sUB_PROJECT_NO);
    			return ((int)(result.ReturnValue));
    		}
    

    The odd part however, is I currently have 2 stored procedures in my application.  The first SP works fine.  I drag it onto my dbml file and all code is autogenerated.  Any idea why it may not be working for this 2nd one?  Or hopefully how I can force it to generate?  The stored procedure that's giving me issues is a little more complex than the other one (joining data from several temp tables), so is it possible my dbml file just doesn't know how to handle the stored proc?

    Thanks.

    Monday, August 8, 2011 10:01 PM

Answers

  • Hello,

    From your description, I made a test on my side. When I draged some stored procedure of AdventureWorks in the dbml, I found the following xml code.

    <!--This stored procedure has two parameters: @StartProductID and @CheckDate-->
    <Function Name="dbo.uspGetBillOfMaterials" Method="uspGetBillOfMaterials">
      <Parameter Name="StartProductID" Parameter="startProductID" Type="System.Int32" DbType="Int" />
      <Parameter Name="CheckDate" Parameter="checkDate" Type="System.DateTime" DbType="DateTime" />
      <ElementType Name="uspGetBillOfMaterialsResult">
       <Column Name="ProductAssemblyID" Type="System.Int32" DbType="Int" CanBeNull="true" />
       <Column Name="ComponentID" Type="System.Int32" DbType="Int" CanBeNull="true" />
       <Column Name="ComponentDesc" Type="System.String" DbType="NVarChar(50)" CanBeNull="true" />
       <Column Name="TotalQuantity" Type="System.Decimal" DbType="Decimal(38,2)" CanBeNull="true" />
       <Column Name="StandardCost" Type="System.Decimal" DbType="Money" CanBeNull="true" />
       <Column Name="ListPrice" Type="System.Decimal" DbType="Money" CanBeNull="true" />
       <Column Name="BOMLevel" Type="System.Int16" DbType="SmallInt" CanBeNull="true" />
       <Column Name="RecursionLevel" Type="System.Int32" DbType="Int" CanBeNull="true" />
      </ElementType>
     </Function>
    
    <!--This stored procedure hasn't any input parameters-->
    <Function Name="dbo.uspPrintError" Method="uspPrintError">
      <Return Type="System.Int32" />
    </Function>
    

    If you have any finding or question, I suggest you can provide your stored procedure in your reply to us to analyze your question better.

    Thanks,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Larcolais Gong Wednesday, August 17, 2011 5:51 AM
    Thursday, August 11, 2011 7:34 AM

All replies

  • Hello,

    From your description, I made a test on my side. When I draged some stored procedure of AdventureWorks in the dbml, I found the following xml code.

    <!--This stored procedure has two parameters: @StartProductID and @CheckDate-->
    <Function Name="dbo.uspGetBillOfMaterials" Method="uspGetBillOfMaterials">
      <Parameter Name="StartProductID" Parameter="startProductID" Type="System.Int32" DbType="Int" />
      <Parameter Name="CheckDate" Parameter="checkDate" Type="System.DateTime" DbType="DateTime" />
      <ElementType Name="uspGetBillOfMaterialsResult">
       <Column Name="ProductAssemblyID" Type="System.Int32" DbType="Int" CanBeNull="true" />
       <Column Name="ComponentID" Type="System.Int32" DbType="Int" CanBeNull="true" />
       <Column Name="ComponentDesc" Type="System.String" DbType="NVarChar(50)" CanBeNull="true" />
       <Column Name="TotalQuantity" Type="System.Decimal" DbType="Decimal(38,2)" CanBeNull="true" />
       <Column Name="StandardCost" Type="System.Decimal" DbType="Money" CanBeNull="true" />
       <Column Name="ListPrice" Type="System.Decimal" DbType="Money" CanBeNull="true" />
       <Column Name="BOMLevel" Type="System.Int16" DbType="SmallInt" CanBeNull="true" />
       <Column Name="RecursionLevel" Type="System.Int32" DbType="Int" CanBeNull="true" />
      </ElementType>
     </Function>
    
    <!--This stored procedure hasn't any input parameters-->
    <Function Name="dbo.uspPrintError" Method="uspPrintError">
      <Return Type="System.Int32" />
    </Function>
    

    If you have any finding or question, I suggest you can provide your stored procedure in your reply to us to analyze your question better.

    Thanks,


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Larcolais Gong Wednesday, August 17, 2011 5:51 AM
    Thursday, August 11, 2011 7:34 AM
  • Hi Goalie,

     

    Just a tip, but maybe helps.

     

    I had something similar before. I tried to add a stored procedure, but it was not fine.

    I spent more than an hour on the issue and it disappeared after I had restarted my visual studio.

     

     


    Regards, Peter

    //If a post answers your question, please click "Mark As Answer".
    //Also if a post seems to be helpful, please click "Mark as Helpful" on that post.
    Thursday, August 11, 2011 8:13 AM