ORM Help for a newb

Discussion in 'OT Technology' started by jdog12, May 4, 2008.

  1. jdog12

    jdog12 New Member

    Joined:
    Nov 27, 2004
    Messages:
    5,474
    Likes Received:
    0
    I'm pretty much a beginner when it comes to development. I'm wanting to do an online store with auction capabilities. I wanted to use an ORM tool rather than just writing straight SQL statements, but was wondering what you all recommend. I'm wanting to do it in ASP with C# code, and am pretty much set on doing that rather than learning something new.

    I have very little experience with NHibernate and no experience with anything else. I have sample code I can use from a class project to help me along the way in implementing it. I was wondering if there is anything superior to NHibernate that will be easier for me to set up and use? Or something that would be overall better.

    Also, what is a good starting point, and what should I look in to when setting this up? I remember a friend of mine saying he set up NHibernate and he had trouble with the sessions, so he told me to look up doing the sessions.
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    why arn't you using stored procedures?
     
  3. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Probably because he's a noob, like he said. Why don't you do something useful, like telling him to use stored procedures, and giving him a link where he can learn how to use them?
     
  4. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    you perceive mallace when there was none. Had I told him to "use stored procedures" you'd jump on my for assuming something. I am asking WHY he's not using them. Now if he doesn't know about them he can say that (or preferably check google, first).

    You WANT to disagree with what I say.
     
  5. jdog12

    jdog12 New Member

    Joined:
    Nov 27, 2004
    Messages:
    5,474
    Likes Received:
    0
    My db skills are lacking and I haven't had much experience with them. Like I said, I'm a noob. I took a db class and we had one stored procedure assignment and didn't go into them very much past that. Got any good links for me? I guess I better get to doing some creative googling.
     
  6. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    what db server? mysql? their site has good documentation.
     
  7. jdog12

    jdog12 New Member

    Joined:
    Nov 27, 2004
    Messages:
    5,474
    Likes Received:
    0
    Ms SQL Server 2005. I get it for free w/ school . I'm testing this on a vm w/ sql server and windows xp. It's the only thing I've ever used too. The only time I've ever done db work is for school and that was either access or MS SQL Server 2000(mostly).
     
  8. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    there are many many books for that.
     
  9. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    NHibernate is a great option. Been used/abused/proven by many production commercial apps and has great developer support.

    If you like the ActiveRecord approach to ORM, Castle has an implementation for .NET http://www.castleproject.org/activerecord/index.html

    EDIT: for the record, you should learn basic sql syntax if you're going to be writing software in the future. however, OR/M technology is a great way to abstract out all of the CRUD pain and makes your app pretty database agnostic
     
  10. aim2kill

    aim2kill New Member

    Joined:
    Mar 19, 2008
    Messages:
    631
    Likes Received:
    0
    Location:
    deployed.
    wow, this hardware guy is drowning [halp!]
     
  11. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    I swear to god, you're channeling me right now.

    I suppose you could've said "Try using stored procedures" instead of "Use stored procedures." That leaves room for error. And it would've been someone else who'd have jumped on your ass for assuming that he hadn't tried stored procedures yet, not me. And I don't want to disagree with you -- I agree with you on a regular basis -- I just happen to disagree with you on a regular basis too.

    Anyway, the specific thing that I had an issue with was how you asked the question as though he should've thought of using stored procedures himself, instead of just suggesting it.
     
  12. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Even if he uses stored procedures, he should still be using ORM. Assuming there is a good lib for that in C#... and there must be. And unless he's writing a big app where the same SQL is being run by multiple applications... he should NOT be using stored procedures. In fact, doing so would be stupid, and an error. His ORM should be generating his SQL for him.
     
    Last edited: May 5, 2008
  13. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    Yeah ActiveRecord sounds ideal for you, and you also always have the ability to dip into NHibernate whenever you need it, seeing as ActiveRecord lies on top of NHibernate.

    The main issue (like a lot of Open Source projects unfortunately) is sometimes the documentation is sparse or lacking, and a lot of the knowledge is fragmented between various newsgroups, forums and blogs.

    You might find more benefit also if you use the overall Castle stack. NVelocity or Brail template engines, on top of the MonoRail MVC framework which then has excellent data binding, validation etc for ActiveRecord. This gets rid of the cluster fuck that is WebForms, Server Controls and View State but also adds another learning curve.

    Oh and stored procedures are so redundant to me right now and have been for a long time. You need a good reason to use a stored procedure, rather than reasons not to.
     
  14. Dnepr

    Dnepr Guest

    Was just about to say the same
     
  15. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    The problem with most ORM libraries is you end up NOT saving time over doing the SQL directly. Most ORM libs suck balls. Writing XML is not better than writing SQL. Writing SQL in another SQL like language is not better than writing SQL.
     
  16. Dnepr

    Dnepr Guest

    It depends.

    For example, using Hibernate in Java with Eclipse or Netbeans and respective plugins is pure joy of simpleness and efficiency (lol).

    It's really fast and easy. It's kinda sad when you know more about SQL performance query writing then our DBA because you had to write so damn many of them yourself.
     
  17. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Oh yeah? Because I find this:

    to be incredibly fail and lame.
     
  18. jdog12

    jdog12 New Member

    Joined:
    Nov 27, 2004
    Messages:
    5,474
    Likes Received:
    0
    What do you recommend then? I could just write SQL, but I figured an ORM would be some good experience. I dunno.

    I'm gonna look into this Activerecord and castle stack. I remember reading something about it a while back, but didn't go into it very much.
     
  19. Dnepr

    Dnepr Guest

    You know, you don't actually have to use XML for mapping with Hibernate.

    You can map tables, relations, etc in code using Hibernate Annotations.


    Once you get familiar with Hibernate, it is much faster to use then writing queries by hand.
     
  20. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    I tend to find iBatis has as little bullshit as possible. They have it for .NET. http://ibatis.apache.org/

    But my favorite ORM is DBIx::Class for teh Perl.
     
  21. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    ActiveRecord abstracts away the lame XML stuff.

    I don't touch the database at all. I actually write my business object classes, and generate/update the database schema automatically from them.

    Also the main benefits of ORMs aren't just staying away from SQL. A couple of things are:

    Database agnostic
    Possibilities for dynamically building complex queries
    Protection against SQL injection
    Easy to test object models
    In-built caching and performance benefits
    Your business logic is in your code, not fragemented across code and SQL

    I'm sure there's lots of other reasons which don't come to mind right now too.
     

Share This Page