Hi,
I would like my users to be able to add entities attributes themselves from UI. It's a common scenario for a professional application and I would appreciate your advice to start implementation.
Basicaly, the user should be able to go in some application settings, and add a property name, a property type and a target entity. As a result, when the user will open an entity (let's say a Product entity) then he will have new attributes displayed.
I have two main ideas in mind :
SOLUTION 1 : create a specific entity, let's say AdditionalAttributes (to store property names and types). Then I will add a ICollection<AdditionalAttributes> to a set of existing entities (the ones I want users to be able to extend). I know how to do this in ASPNETZERO context from domain layer to presentation layer. Don't know if this will lead to performance issues or whatever bad.
SOLUTION 2 : adding an XML property to each entities to extend. I don't have much experience on this approach and don't know how to implement this on UI side at least. See here : [https://stackoverflow.com/questions/30783224/dynamically-adding-a-property-to-an-entity-framework-object])
Do you have other solutions in mind ? What's your advice as ASPNETZERO experts ?
1 Answer(s)
-
0
Duplicate of #4539@2b82272b-4716-4d48-bc1d-03db40b526f2
<cite>ismcagdas: </cite>
ASP.NET Zero doesn't support this. ABP Framework defines IExtendableObject interface. You can give it a try but it is not possible for us to write down all the steps for your scenario, it is out of the support scope.
<cite>ismcagdas: </cite>
If you want to use IExtendableObject, then you have to implement it in your entity you want to use it. But, this will store custom data in a single column with json format. You can also use ExtendableObjectExtensions to manipulate this data when you get it from database.
The main problem using this data is, you cannot create SQL server indexes using a specific field in your custom data. It is also hard to query using a custom data column from SQL Server.
- Documentation: IExtendableObject Interface
- More examples: ExtendableObject_Tests.cs