Dependency injection (DI) Domain Entities

11 个月 前
if we have some additional properties to be added to nopCommerce Entities e.g. [BlogComment] class,
we did not see that its implementing an interface, so we can inject our concrete class that will substitute the original nopCommerce class.

so is there a way to doing that without touching the original nopCommerce code.
so we can inject our substitute entities in our plugins, and they will change the Original Entities.
11 个月 前
The Domain objects/classes are just POCO.
It's a 'partial class', so it can be extended, but only within the same Project/Assembly, not in a plugin.

If you really want to isolate your 'changes' to a plugin, then consider creating an additional 1-1 table, or use GenericAttributes.
11 个月 前
thanks a lot for the fast response.
is there a way, that we can intercept the updating of the copCommerce domain entity objects before being retrieved from the database, or before updating?
as we have added a new primary key in most of the nopCommerce tables called [tenantId], for our Multi-Tenant architecture.
and as u know, if the field is a primary key, then we can update without inserting  a value in it, and when retriving data, we want to retrieve only the tenantId info we want.
and this field as said before in most if not all nopCommerce tables is a primary key, without touching nopCommerce code.

Regards.
11 个月 前
You can override any service so in the case of Products you can override the ProductService for example the routines GetProductByIdAsync or UpdateProductAsync
This is best done in a Plugin so you are not modifying the core code

Out interest How does Multi-Tenant differ from Stores ?
11 个月 前
thanks a lot for ur response.
we are using the [VendorId] as the [TenantId], but its used in some tables in nopCommerce, and not in most of them.
and we want to use horizontal scaling, by sharding the database over the [VendorId], so each vendor, will have his database on a different [server/container/node], and this needs to have most of the tables that have specific data per vendor, to have a key [VendorId].

Regards.