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.
Hace 5 años
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.
Hace 5 años
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.
Hace 5 años
Yes I had already map Model and the DbSet property.
While accessing as normal way it's working but SP not working.
Hace 5 años
[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.
Hace 5 años
i had set same output property as SP execute still not working.
Hace 5 años
Can you try below way?

_dbContext.ExecuteStoredProcedureList<"Return Class">("Sp Name",
                    parameter1,
                    parameter1)
Hace 5 años
It can be help for you.

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

Thank you
Sagar Kayasth
Hace 5 años
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();
Hace 5 años
I created a stored procedure on install.
Hace 5 años
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.