0

A inhouse vb.net ORM has been developed using stored procedures to get the data to populate individual objects in a complex hierarchy. We have moved from a stored procedures for each mapping action to dynamic sql which is built up at runtime and executed which should increase functionality and performance. Each class has its own mapping code stating property to db column mapping, table, cardinality etc.

My issue is that due to complexities of the object model, an object being built by the ORM/mapper code will call potentially more data than is needed and thus hamper performance.

Is this an issue with the object model or the ORM or both?

Could anybody suggest a design pattern/idea to help administer this issue?

My first thoughts were that we should have extra functionality in out mapping classes to control the depth of the data retrieved but how could this be achieved cleanly i don't know. any ideas or thought on this subject will be greatly recieved.

4
  • By more data, do you mean the relational data of an object, which you store as a property (single row or multiple rows?) Aug 24, 2012 at 9:48
  • I hope this makes sense but by more data, i mean that the mapping class and subsequent child mapping classes build a single sql statement based on the object hierarchy which may mean that you get 100s of rows of data in a single call. which is returned and mapped back to a single object with 100s of children as an example. The problem lies with each object having its own mapping so that class A will then use the mappings for class b and so on.. to class z. When i may only need the class a and b.The issue lies with performance and the posibility of recursion.
    – Richard
    Aug 24, 2012 at 10:04
  • I would go with the lazy fetching as Vikdor suggested, also take a look at the Repository Pattern and dapper-dot-net Aug 24, 2012 at 11:42
  • This problem is solved very well by ORMs that already exist and while building a custom ORM is fine, this problem is not really easy to solve in your custom ORM so you should really considering using an existing ORM rather than continue down this path of recreating NHibernate, etc. from scratch. Aug 25, 2012 at 10:57

1 Answer 1

0

ORMs like Hibernate deal with this scenario using "Lazy Fetch" strategy where the object associations to any depth are maintained as is, but the objects in the hierarchy are fetched on demand when they are accessed for the first time. You might want to look at Proxy Pattern to get an idea of how this could be done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.