0

I am using nop commerce e-commerce open source 1.9 in which they use the Entity Framework.

They have one stored procedure which loads all the products and map that stored procedure to sp_ProductLoadAllPaged function

Now I change that stored procedure and in out put of that sp their is one more column which is languages.

I also declare the languages property in product.cs class file.

But now as I use quick watch languages column is null for all products.

I updated the .edmx file from database in model browser.

Now I check that I am missing some mapping of languages attribute which in class and stored procedure

So please tell me how to map this new column of stored procedure to product class languages properties.

please see the below image for more information

mapping image

As you can check the stored procedure final select statement where I made changes to get the languages of that product

SELECT  
        p.ProductId,
        p.Name,
        p.ShortDescription,
        p.FullDescription,
        p.AdminComment,
        p.TemplateId,
        p.ShowOnHomePage,
        p.MetaKeywords,
        p.MetaDescription,
        p.MetaTitle,
        p.SEName,
        p.AllowCustomerReviews,
        p.AllowCustomerRatings,
        p.RatingSum,
        p.TotalRatingVotes,
        p.Published,
        p.Deleted,
        p.CreatedOn,
        p.UpdatedOn,
        p.AmazonLink,
        p.ProductCode,
        p.CategoryText,
        STUFF((Select ','+ [Name] from Nop_Language where Nop_Language.LanguageId in
    (Select Nop_ProductLocalized.LanguageID
    from
        Nop_ProductLocalized
    where
        ProductID=p.ProductId
    ) for xml path('')),1,1,'') as 'languages'
    FROM
        #PageIndex [pi]
        INNER JOIN Nop_Product p with (NOLOCK) on p.ProductID = [pi].ProductID
    WHERE
        [pi].IndexID > @PageLowerBound AND 
        [pi].IndexID < @PageUpperBound
    ORDER BY
        IndexID
4

1 回答 1

0

仅仅修改类是不够的。新属性必须在 EDMX 中已知,并且来自 EDMX 的模板必须在类中为您生成该属性。

因此,如果sp_ProductLoadAllPaged是实体,您必须在 EDMX 中手动添加属性并对其进行映射。如果它是复杂类型,您必须在函数导入向导中更新复杂类型。如果您将其作为 XML 打开(在进行手动更改之前将当前版本保存在某处),您也可以直接在 EDMX 中执行这两种方法。

于 2011-11-10T09:56:22.703 回答