11 Replies - 3737 Views - Last Post: 25 December 2010 - 10:42 PM

#1 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 784
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Are you using ORM tools?

Post icon  Posted 22 December 2010 - 06:18 PM

Recently I've seen lots of developers (especially in the .NET community) rely on ORM (object relational mapping) tools, basically minimizing direct interactions with the database and using an abstraction layer built on top of an extensible (RDBMS-independent) platform.

I recently started using LINQ-to-SQL (duh! since I am working with .NET) and planning to take a look at Entity Framework.

Are you using any ORM tools in your applications or you still rely on plain and simple direct database connectors?

Is This A Good Question/Topic? 2
  • +

Replies To: Are you using ORM tools?

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5537
  • View blog
  • Posts: 14,539
  • Joined: 18-April 07

Re: Are you using ORM tools?

Posted 22 December 2010 - 06:45 PM

Well it has been a long standing practice to create a middle layer (abstract layer) on top of a data source of some kind... be it mostly a database, but could be any service really. Very rarely do you ever want actual program code to touch the datasource. Plus this middle layer is a perfect opportunity to implement business rules and concepts. Something that the programming language is not concerned with and the database doesn't care about.

Now I haven't used tools for this and typically I have had to write the middle layer myself using standard connector style objects. This has worked plenty well for me. Usually if you write them once, they are good for awhile. Switch databases and you simply switch out the middle layer with it. Sound familiar? Right, this is essentially an API. Never really had the need to go all fancy with ORM tools or anything.

I did have to work a database once built with this virtual object idea integrated into it. Was a nightmare! For those would be database designers out there, never ever go the route of creating virtual objects integrated into the database and break classic SQL. Let RDBs be!

:)
Was This Post Helpful? 2
  • +
  • -

#3 redkid   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 32
  • Joined: 23-April 09

Re: Are you using ORM tools?

Posted 22 December 2010 - 06:47 PM

Yep. It's just a mess without them. And design patterns are useless otherwise.

EF Code First is magnificent and only can get better as it's in CTP now. Also, EF is supposed to be standard for .Net, so don't get too used to LINQ2SQL. Even then though, the curve is not too steep.
Was This Post Helpful? 2
  • +
  • -

#4 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 784
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: Are you using ORM tools?

Posted 22 December 2010 - 06:51 PM

Martyr2 - were the databases that stored virtual objects NoSQL by any chance or those were homebrewed entities?

Haven't worked extensively with EF yet - just glanced on it and saw how to implement basic connections. I don't think that it will be really hard to switch to it with LINQ-to-SQL background.

I would have to agree, though, that EF eventually will replace LINQ-to-SQL as the fundamental .NET ORM, considering current development investments.
Was This Post Helpful? 0
  • +
  • -

#5 redkid   User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 32
  • Joined: 23-April 09

Re: Are you using ORM tools?

Posted 22 December 2010 - 07:16 PM

View PostCore, on 22 December 2010 - 05:51 PM, said:

I would have to agree, though, that EF eventually will replace LINQ-to-SQL as the fundamental .NET ORM, considering current development investments.


Actually, according to what I've read, EF team missed deadlines for VS10 that's why it wasn't shipped, otherwise it would have been packaged with VS10. LINQ2SQL was never meant to be the ORM that it is.

Nonetheless, LINQ2SQL is pretty sweet for MVC projects, it's actually simpler than EF, I find, but much less flexible and not at all automated. EF on the other hand is made for all that plus a whole lot of stability.

This post has been edited by redkid: 22 December 2010 - 07:20 PM

Was This Post Helpful? 1
  • +
  • -

#6 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 784
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: Are you using ORM tools?

Posted 22 December 2010 - 09:28 PM

View Postredkid, on 23 December 2010 - 03:16 AM, said:

Nonetheless, LINQ2SQL is pretty sweet for MVC projects, it's actually simpler than EF, I find, but much less flexible and not at all automated. EF on the other hand is made for all that plus a whole lot of stability.


MVC is what actually got me started with this. It's fairly easy to build common data models and repositories with a little of LINQ-to-SQL instead of packing it with EF. Which is especially nice for smaller projects.
Was This Post Helpful? 0
  • +
  • -

#7 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Are you using ORM tools?

Posted 23 December 2010 - 05:42 AM

Using Entity Framework 4 for pretty much all of my projects. It's very nice to work with and supports a lot of different data providers, from MSSQL to MySQL to SQLite. It just works.

It's great to create a model and automatically have your POCO objects generated and available for use in code. It especially works well on MVC applications because you can create your model .edmx file, then create your repository files, and done. You can now access data from your controllers using the repository files as your "DAL" layer.
Was This Post Helpful? 1
  • +
  • -

#8 girasquid   User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: Are you using ORM tools?

Posted 23 December 2010 - 08:24 AM

I made the switch to ORMs for all my new development work back in 2008 - I've had a chance to check out Django's ORM, ActiveRecord (Rails' ORM), SubSonic, and most recently IdeaBlade.

Honestly, after using ORMs as heavily as I have been the past few years, I don't think I'd ever go back. In the (rare) situation where I need something the ORM I'm using can't do, there's generally some sort of binding to let me run raw SQL if I need to.

Overall, I'd say using an ORM instead of a direct database connection and hand-written SQL commands has probably saved me at least a week's worth of implementation time over the last 2 years, and probably double that in debugging time.
Was This Post Helpful? 1
  • +
  • -

#9 keakTheGEEK   User is offline

  • D.I.C Regular
  • member icon

Reputation: 108
  • View blog
  • Posts: 344
  • Joined: 23-February 10

Re: Are you using ORM tools?

Posted 23 December 2010 - 02:07 PM

We're also using a traditional long standing practice as described by @Martyr2. Haven't used any ORM tools yet. We are always having debates and bumping heads regarding database programming with the team of developers that I am working with now. Most of us are proficient in database programming, but a few of us (the ones that have the most say so) admit that their sql coding chops aren't that great. A few months back I looked at Linq2SQL to see if this would give us the best of both worlds if we were to start using it.

I did some obsessive research on Linq2Sql to find out if there was any benefit in using it for someone who is quite comfortable doing pure database programming. Linq2Sql looks like a cool feature, but my initial impressions about it were a bit skeptical. I looked at a lot of polls online regarding it and almost all of them were split 50/50. Half in favor of it seemed to have a phobia of programming sql in general (based on my observations by some of the comments); the other half who didn't care for it seemed to be very proficient in database programming. Then, the idea of relying on an ORM tool to generate the SQL code for you didn't sit well with me at first. What if the sql code being generated isn't the most optimal (particularly with a database that is highly normalized and very complex)? But then I found out that you can modify the sql code if needed. So, overall Linq2Sql seemed like a cool feature to start using... But then all of that went out of the window after reading about Microsoft abandoning any future development on it :no:

So now I am just getting started looking into Entity Framework. I don't really know much about it yet as I have only watched a couple video tutorials on it. One of the features that I keep hearing about it is that it doesn't matter what RDBMS you are using. This is great and I can see how beneficial that can be, but what I want to know is if it can take advantage of features that are specific to the RDBMS that is being used. For example, MS SQL Server introduced User Defined Data types in version 2005. Then in SQL Server 2008, Microsoft introduced the ability to pass a user defined type that had a table variable as the underlying data structure to a stored procedure (essentially, passing a table variable as a parameter to a stored procedure). On the .NET side, I can pass a populated DataTable (its entirety) as a parameter to the stored procedure using plain old vanilla ADO .NET. Can something like that be done using EF? These are questions that I have in mind while reading up on EF...

Also, I might add that I generally have a phobia about using SQL generating ORM tools because I am affraid that my SQL programming skills will start to fade if I start relying on them.

This post has been edited by keakTheGEEK: 23 December 2010 - 02:11 PM

Was This Post Helpful? 1
  • +
  • -

#10 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 784
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: Are you using ORM tools?

Posted 23 December 2010 - 03:42 PM

I wouldn't be afraid too much about my SQL skills fading because I still do a lot of, let's say - "native" SQL operations - especially for extremely large queries. What I found recently that when you are operating with large chunks of data, LINQ-to-SQL really loses in performance compared to native, RDBMS-optimized queries.
Was This Post Helpful? 0
  • +
  • -

#11 dawmail333   User is offline

  • D.I.C Head
  • member icon

Reputation: 28
  • View blog
  • Posts: 174
  • Joined: 02-July 07

Re: Are you using ORM tools?

Posted 23 December 2010 - 04:26 PM

I started using Linq-to-SQL for an assignment I had, where we had to use SQL, but the teacher said he wanted to see raw SQL. The database sucked, so it actually made it a bit easier for me: I used the handler's ExecuteSQL function, told it what I expected back, and voila: much easier than using Datareaders...

So yeah, it helped even though I was writing my own raw SQL, by returning strongly typed objects.
Very useful, considering how CRAPPY the database was (using highschool normalisation processes, the main table should have been split into seven(!))

I'm using Linq-to-Entities for my latest project. It hasn't really gotten too far yet, but it looks to be useful, especially seeing I'm manipulating student data, from multiple sources, with a web project as an API, and a Silverlight project as the front-end. Sounds perfect to me.
Was This Post Helpful? 0
  • +
  • -

#12 dorknexus   User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1272
  • View blog
  • Posts: 4,625
  • Joined: 02-May 04

Re: Are you using ORM tools?

Posted 25 December 2010 - 10:42 PM

When working with Java I've used Hibernate for ORM type stuff. However, after using both Django and Rails the hibernate stuff seems pretty bleh in comparison. I haven't worked to in depth with the ORM support in Django but I know Rails has a very very rich ORM set.

ORM will never completely replace your communication with the database as it does not always make the most optimized queries. However, I'd say about 80-90% of what it does generate is just fine.

The two biggest advantages of using ORM are that

1.) It allows you to talk about data in terms of objects (which is useful in OO design).
2.) It decouples your software from the data source. I love being able to just hot swap database drivers and be compatible with any major DBMS.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1