nopCommerce 4.10 Custom Plugin Data Access with SP not Working

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hello Guys,

I am using nopCommerce 4.10 version and i have created one new plugin which works perfectly if i am use lambda expression (existing structure) for getting data from database but while using Store Procedure it's not working. Below is my code for getting data also i have already use dependency register, context and everything which required but still i am missing to register my new class?

var query=_dbContext.EntityFromSql<myclassname>("my_sp_name", param1,param2).ToList();


Getting error : 'Cannot create a DbSet for 'myclassname' because this type is not included in the model for the context.'


Note: I have built the same structure as existing nopCommerce.
5 years ago
Have you created the Model and the DbSet property within your context model? EntityFramework will need to know the properties to map SQL results to the Model.
5 years ago
Yes I had already map Model and the DbSet property.
While accessing as normal way it's working but SP not working.
5 years ago
[email protected] wrote:
Yes I had already map Model and the DbSet property.
While accessing as normal way it's working but SP not working.



Properties in Model that you have define in DbSet should be the same as the result of Stored Procedure.
5 years ago
i had set same output property as SP execute still not working.
5 years ago
Can you try below way?

_dbContext.ExecuteStoredProcedureList<"Return Class">("Sp Name",
                    parameter1,
                    parameter1)
5 years ago
It can be help for you.

_dbContext.ExecuteSqlCommand($"EXEC [{StoredProceduresName}] @param1", false, null, pParam1);

Thank you
Sagar Kayasth
5 years ago
I am having the same issue, so how should I code my sql query for sp that doesn't exist??


var records = _dbContext.EntityFromSql<MyTable>("MyTableLoadAllPaged",
                pStoreId,            
                pLanguageId,
                pPageIndex,
                pPageSize
                ).ToList();
5 years ago
I created a stored procedure on install.
5 years ago
ritul wrote:
Can you try below way?

_dbContext.ExecuteStoredProcedureList<"Return Class">("Sp Name",
                    parameter1,
                    parameter1)


There is no ExecuteStoredProcedureList method for IDbContext.

when I try


var qry = _dbContext.ExecuteSqlCommand($"EXEC [EntityLoadAllPaged] @Keywords, @UseFullTextSearch, @FullTextMode, @OrderBy, @PageIndex, @PageSize", false, null, pKeywords,
                pUseFullTextSearch,
                pFullTextMode,
                pOrderBy,
                pPageIndex,
                pPageSize);


this turns int. How can I get List<Entity> out of it. I already have my stored procedure in my sql server
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.