Anzahl der Beiträge:
9
Karma:
45
Beigetreten:
11.05.2021
Herkunft:
Australia
Hello All, I am working on NoP version 4.20 I created a widget and now want to show data from a sql view that I created in database but I do not see any way to get data from my view in nopcommerce. I can only access tables through Entity Framework. I tried to use QueryFromSql method but it can also get data from a model if it is added in context. Please help!! Regards, Jitender Dhaliwal
Zertifizierter Entwickler
Anzahl der Beiträge:
357
Karma:
3116
Beigetreten:
09.12.2018
Herkunft:
Bangladesh
There is no other way, you have to use either a entity or a query type model Check ProductTagWithCount at Nop.Core.Domain.Catalog and it's db map on ProductTagWithCountMap at Nop.Data.Mapping.Catalog
Anzahl der Beiträge:
11329
Karma:
101037
Beigetreten:
22.05.2011
Herkunft:
United States
It can be done: private readonly INopDataProvider _dataProvider; ...(use construcot injection) var results = _dataProvider.Query<someClass>(sql).ToList();
Anzahl der Beiträge:
9
Karma:
45
Beigetreten:
11.05.2021
Herkunft:
Australia
Thank you for your responses, I am able to get data by overriding OnModelCreating of DBContext in the Plugin. Added this line in overload method and after this it gets data from the sql query and view. modelBuilder.Query<MyReturnClass>(); Also added a mapping for the view in the Plugin.