3

Ok I know "what X should I use" is very broad so let me narrow down our usage scenario. Basically, we should have been using an ORM a long time ago. Now though there is no way we can go through and rewrite every line of generated SQL Queries in our C# code. But we want to at least take a few steps in the right direction. So when we write new code(and in free time with refactoring) we want to convert over to some sort of ORM.

What would be a good ORM for this purpose? We are using .Net 3.5 and ASP.Net(webforms). There is nothing insanely complex about our database except for a few tables have a "dynamic" schema. We have a numerous amount of views(not used by the web application much though) and we have/use very few stored procedures. Our database is SQL Server 2005. Our price range is as cheap as possible and open source is preferred. This is a proprietary project however so we can't use a GPL library and such.

About the dynamic schema: Basically in some instances a column(of varying types) can be added or removed to certain tables.

And our view usage is almost non-existent and we could always take out the stored procedure code.. I believe there is only 2 or 3 in the database.

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • 1
    MyBatis.NET (former iBatis) http://www.mybatis.org/ and http://code.google.com/p/mybatisnet/ – Imre L Jul 06 '10 at 16:46
  • possible duplicate of [Which ORM for .NET would you recommend?](http://stackoverflow.com/questions/132676/which-orm-for-net-would-you-recommend), http://stackoverflow.com/questions/3505/what-are-your-favorite-net-object-relational-mappers-orm, and http://stackoverflow.com/questions/206197/best-free-orm-tools-to-use-with-net-2-0-3-5 – Corbin March Jul 06 '10 at 16:48
  • @Corbin I'm looking for a more personalized opinion. I am completely new to ORMs but I know that not every ORM out there is going to fit my needs well. – Earlz Jul 06 '10 at 16:49
  • @Earlz, I realize everyone has unique needs, but if we add a question for every unique project it seems that we'll have incredible duplication. The questions above contain answers that describe pros and cons and scenarios where the ORM is appropriate. I think they'll be able to help you without a brand new question. – Corbin March Jul 06 '10 at 16:53
  • 2
    http://stackoverflow.com/questions/1377236/nhibernate-entity-framework-active-records-or-linq2sql – Michael Maddox Jul 06 '10 at 17:16
  • @Corbin well also look at how old that possible duplicate is... all the posts are from 2008. Surely something has changed in 2 years. – Earlz Jul 06 '10 at 17:25

4 Answers4

8

Massive - https://github.com/robconery/massive

or

PetaPoco - https://github.com/toptensoftware/petapoco

Both are single .cs files with no dependencies except what's in the GAC.

(full disclosure, PetaPoco is something I wrote)

Brad Robinson
  • 44,114
  • 19
  • 59
  • 88
4

I would say that for .NET 3.5 you could use LINQ to SQL which is free, supports Views and Stored Procedures, and has a small learning curve. The only thing I think you'd run in to trouble trying to use would be your "dynamic schema" tables (which you might want to elaborate on).

Another Open Source alternative would be nHibernate which is a great ORM, but has a much steeper learning curve in my opinion.

Justin Niessner
  • 242,243
  • 40
  • 408
  • 536
3

I would second Justin on suggesting Linq-to-SQL - it's really not dead!

If that's not your choice, or if you need to go against something like SQLite, you should definitely also check out Subsonic 3.0 - lightweight, easy to use, free, with source - you name it.

Chris
  • 329
  • 2
  • 11
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Subsonic has a really small learning curve and I got it up and running and doing the first query in about 30 minutes in our project.. It seems like the tool for the job.. – Earlz Jul 06 '10 at 20:27
  • Note: I wouldn't recommend SubSonic to anyone anymore. It doesn't support joins at all. Any join will do a full table scan. However, the project [BLToolkit](http://bltoolkit.net/default.aspx?AspxAutoDetectCookieSupport=1) is similar, but has working joins – Earlz Nov 21 '12 at 21:01
1

I enjoy using SubSonic for easy data access it generates classes using T4 so it really easy to change what is being generated. Its more of an active record style data access then a true ORM like nHibernate but linq to sql isn't a true ORM either.

Aaron
  • 1,031
  • 10
  • 23
  • SubSonic is awesome assuming you never need to do joins. For this project(at the time), we used SubSonic and then a year later after figuring out it's huge performance problem with joins, rewrote it in another T4 generating ORM (that I can't remember right now) – Earlz Sep 16 '12 at 00:56
  • I would be interested in the name if you think of it I like t4 feature a lot. – Aaron Sep 17 '12 at 23:47
  • 1
    Just going to update you. Finally remembered the name of the SubSonic replacement I used: [BLToolkit](http://bltoolkit.net/default.aspx?AspxAutoDetectCookieSupport=1). Bit higher learning curve, but it's joins are actually joins. Not full table scans – Earlz Nov 21 '12 at 21:00