Hi,
I need to work with custom entities and I do not wish to have loads of tables. So I have come up with an idea of having one generic "Class" table with is then link to a "Group" table with custom column of string type.
ie C1, C2, C3.
It seems to me that there could be 2 methods to create the specific entities via ED.
1) Create a DB View for each "Group" and create an entity for each view by editing the "Mapping Details". Incidentally, although it says <Add a Table or View>, I can only see my tables? Is this a bug or am I missing something. The View definitely exists.
2) Use the Query View facility in the "Mapping Details" option and write the appropriate Entity-SQL. With this approach, one would not need to write specific DB Views. Would these be updatable like DB Views as long as I accessed just one table?
Thanks.
Best approach to map custom entities against generic tables?
Re: Best approach to map custom entities against generic tables?
I may be moving forward on this.
I have added a View in my Model by choosing "New Defining Query". I then wrote my SQL which was something like "Select * from vwProduct". I then name my View "vwProduct" and then created a class from it. I could then "retrieve data" from this Class and all is fine. However how can I test that it will accept data, ie how do I do an insert and edit?
Please also comment on whether there are other approaches to my aim of creating custom entities against generic tables.
Thanks.
I have added a View in my Model by choosing "New Defining Query". I then wrote my SQL which was something like "Select * from vwProduct". I then name my View "vwProduct" and then created a class from it. I could then "retrieve data" from this Class and all is fine. However how can I test that it will accept data, ie how do I do an insert and edit?
Please also comment on whether there are other approaches to my aim of creating custom entities against generic tables.
Thanks.
Re: Best approach to map custom entities against generic tables?
We recommend you to implement the following approach:
1. In Model.Store (Model Explorer) right click on the Tables/Views node > Add > New Defining Query > set Entity Name and specify SQL Query (select all needed columns from one or several tables/views).
2. In Model.Store (Model Explorer) right click on the Stored Procedures node > Add > New Command Text - create three insert/update/delete procedures in this way with the needed DML statement in each of them.
3. Drag&drop entity to the conceptual part of the model (within Model Explorer or on a diagram surface).
4. Right click on the class > Stored Procedure Mapping and map Insert/Update/Delete commands to insert/update/delete procedures.
A similar approach (but for a different task) was applied at http://forums.devart.com/viewtopic.php? ... 510#p86947.
1. In Model.Store (Model Explorer) right click on the Tables/Views node > Add > New Defining Query > set Entity Name and specify SQL Query (select all needed columns from one or several tables/views).
2. In Model.Store (Model Explorer) right click on the Stored Procedures node > Add > New Command Text - create three insert/update/delete procedures in this way with the needed DML statement in each of them.
3. Drag&drop entity to the conceptual part of the model (within Model Explorer or on a diagram surface).
4. Right click on the class > Stored Procedure Mapping and map Insert/Update/Delete commands to insert/update/delete procedures.
A similar approach (but for a different task) was applied at http://forums.devart.com/viewtopic.php? ... 510#p86947.
Re: Best approach to map custom entities against generic tables?
Ok, Thanks for this. Will take a look.
Ed
Ed