Need help getting the Entity Framework to implement new stored procedure

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 anni tempo fa
Hello,

I have created a SP in NOP1.7 that returns a recordset with two fields.  I was able to update the NopModel.edmx file.

Here are the entries in this xml file:

<Function Name="Sp_ProductShortDescription_Load" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
          <Parameter Name="ProductID" Type="int" Mode="In" />
        </Function>

<FunctionImport Name="Sp_ProductShortDescription_Load" ReturnType="Collection(NopSolutions.NopCommerce.BusinessLogic.Data.ShortDescription)">
          <Parameter Name="ProductID" Mode="In" Type="Int32" />
          </FunctionImport>

<ComplexType Name="Sp_ProductShortDescription_Load_Result">
          <Property Type="String" Name="Key" Nullable="false" MaxLength="400" />
          <Property Type="String" Name="Value" Nullable="false" MaxLength="400" />
        </ComplexType>

<FunctionImportMapping FunctionImportName="Sp_ProductShortDescription_Load" FunctionName="NopSolutions.NopCommerce.BusinessLogic.Data.Store.Sp_ProductShortDescription_Load">
          <ResultMapping>
              <ComplexTypeMapping TypeName="NopSolutions.NopCommerce.BusinessLogic.Data.ShortDescription">
                <ScalarProperty Name="Key" ColumnName="Key" />
                <ScalarProperty Name="Value" ColumnName="Value" />
                <ScalarProperty Name="ID" ColumnName="ID" />
              </ComplexTypeMapping>
            </ResultMapping>
          </FunctionImportMapping>

I also have a partial class with two public variables 'Key' and 'Value'.  I have also added the following to the 'NopObjectContext.cs' file:

public List<CustomDescription> Sp_ProductShortDescription_Load(int ProductID)
        {
            ObjectParameter productIdParameter = new ObjectParameter("ProductID", ProductID);

            var result = base.ExecuteFunction<CustomDescription>("Sp_ProductShortDescription_Load",
                productIdParameter).ToList();
            return  result;
        }

When I run the app I get the following error:

'The type parameter 'NopSolutions.NopCommerce.BusinessLogic.CustomDescriptions.CustomDescription' in ExecuteFunction
is incompatible with the type 'NopSolutions.NopCommerce.BusinessLogic.Data.ShortDescription' returned by the function.' thrown by the function Sp_ProductShortDescription_load in the 'NopObjectContext.cs' file.

Can someone please help?  I am running out of ideas :(


Bazman
13 anni tempo fa
Hi baaba

Match the spelling of columns  which you are returing form Stored Prodceure with CustomerDescription class.

Thanks
Noman Mansoor
13 anni tempo fa
Delete and recreate the .edmx file.
13 anni tempo fa
Try the link at my post https://www.nopcommerce.com/boards/t/6370/how-to-extending-nopcommerce.aspx
Hope this help!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.