Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a business model wrapper for a generic database approach?
    primarykey
    data
    text
    <p>I'm currently facing a performance problem with creating POCO objects from my database. I'm using Entity Framework 4 as OR-Mapper. The whole application is a prototype for now.</p> <p>Let's assume I want to have some business objects like classes 'Printer' or 'Scanner'. Both classes inherit from a BaseClass called Product. The business classes exist.</p> <p>I try to use a more generic database approach. I don't want to create tables for "Printer" nor "Scanner". I want to have 3 tables: One called Product, and the other Property and PropertyValue (which stores all assigned values to a specific Product).</p> <p>In my business layer I do create a specific object like this:</p> <pre><code>public Printer GetPrinter(int IDProduct) { Printer item = new Printer(); // get the product object with EF // get all PropertyValues // (with Reflection) foreach property in item.GetType().GetProperties // { // property.SetValue("specific value") // } return item; } </code></pre> <p>This is how the EF model looks like: <img src="https://i.stack.imgur.com/rwADO.png" alt="enter image description here"></p> <p>Works fine so far. For now I'm doing performance tests for retrieving multiple sets.</p> <p>I've created a prototype and improved it several times to increase the performance. It is still far away from being usable. I takes 919ms to create 300 objects who only contain 3 properties.</p> <p>The reason for choosing such DB design is to have a generic database design. Adding new properties should only be done in the business model.</p> <p>Am I just being too stupid to create a performant way of retrieving xx objects or is my approach totally wrong? As far as I understand OR-Mapper, they are basically doing the same?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload