Quantcast

Maximum PC

It is currently Sat Apr 19, 2014 6:21 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: I hate you, ORM...
PostPosted: Thu May 12, 2011 6:51 am 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
OK, so this is a project I'm wanting to get started. Let me give you a bit of backstory.

A few weeks ago, I switched out from a traditional DAL w/ POCO to using an ORM. To the unfamiliar, here are some terms:

DAL = Data Access Layer, you use this to perform data gathering/access functions. Whether you're talking to a database or a web service.
POCO = A play on POJO, or Plain Old Java Objects, it means Plain Old CLR Objects. I call them State Bags because they're .NET objects w/ no behavior, only state (data).
ORM = Object Relational Model, it's an object representation of your data store. So a table is an object, per se.

What pissed me off where the following.

1. In Entity Framework/OpenAccess ORM, there is a context object that you need to instantiate. This object maintains a scope with the datastore, so objects you retrieve from the datastore is, in essence, tied to the scope of the context. If you instantiate multiple contexts (e.g., in ASP.NET, the page life cycle drives object life and death), you can't pass an ORM object between separate contexts.

2. Most ORM objects cannot be serialized into XML, so good luck using remoting or any sort of a service tier where you need to serialize objects.

3. It's freakin' slow. Any schema change requires that you update the ORM meta-data. Not a big deal but it's still annoying.

There's already a project called Dapper.NET, but it doesn't handle relationships which is a huge bummer. Dapper also doesn't do query generation (IIRC) and it's merely an extension of IDBConnection. I don't want to fork the project from Github, plus I'm kinda bored and would like to work on a new'ish project. Ideally, this new data mapper should do the following:

1. Be able to use POCO types.
2. Should have a simple object model.
3. Should be intuitive.
4. Should handle relationships.

Coincidentally, I hate this about ORM's as well:
Code:
// To update an object
var myItem = context.Items.Where(x => x.Id == 1).SingleOrDefault();
if (myItem != null)
  myItem.ItemNumber = "1234567890"; // update it

context.SaveChanges();


What I hate about this is that the context holds onto the queried object. While it looks simple, it's not intuitive, ideally you should do this:
Code:
var myItem = context.Items.Where(x => x.Id == 1).SingleOrDefault();
if (myItem != null)
  myItem.ItemNumber = "1234567890"; // update it
context.Update(myItem);


Mainstream ORM's also handle multiple commands. They can create a command queue and execute them in FIFO order. However, mine won't do this. It's designed to be simple. If you want in on the project, let me know, I think it'll be a lot of fun plus it can be a MaxPC open source project! :D

We can create a "project charter" that lists what we hope to accomplish.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group