Coffeehouse Thread

29 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Tackling ORM: Save my fingers!

Back to Forum: Coffeehouse
  • User profile image
    W3bbo

    I'll be taking on a medium-sized web application within the next few days (and underbid for the project, oh how I hate negociations, BTW this was a real-life thing, nothing involving Guru or GetAFreelancer)

    Anyway a lot of it will involve a lot of your standard CRUD operations, but I've been stung before and I don't want to have to write a load of sprocs for each fairly standard operation, then a bunch of simple data-holding classes (that have no methods).

    I'm not keen on ORM classes because it seems a kludge. Whilst you can give them methods that interact with the database it gets complicated when dealing with relationships.

    From what I've read, the strongly-typed DataSets look ideal, but they're more for desktop applications and not webapps.

    Any recommendations?

  • User profile image
    Dr Herbie

    W3bbo wrote:


    From what I've read, the strongly-typed DataSets look ideal, but they're more for desktop applications and not webapps.



    Why do you say they're more for desktop?  I thought they were supposed to be generic.

    I would go for datasets, delivered by a separate DAL-type assembly so that you can nicely separate out the data source from the consumer for effective unit testing sans database.  Datasets and data accessors are quick to create in the IDE.


    Herbie

  • User profile image
    W3bbo

    Dr Herbie wrote:
    Why do you say they're more for desktop?  I thought they were supposed to be generic.


    In ASP.NET objects have a very short lifespan, operations are completed in a single sweep then shut down. Unlike in desktop apps where you use the same DataSet instance for retreiving the data to populate a form then edit the data and persist it, in ASP.NET you populate a form, then start over and this time edit the data, then start over and edit it and persist it.

  • User profile image
    Dr Herbie

    W3bbo wrote:
    
    Dr Herbie wrote:
    Why do you say they're more for desktop?  I thought they were supposed to be generic.


    In ASP.NET objects have a very short lifespan, operations are completed in a single sweep then shut down. Unlike in desktop apps where you use the same DataSet instance for retreiving the data to populate a form then edit the data and persist it, in ASP.NET you populate a form, then start over and this time edit the data, then start over and edit it and persist it.


    Ah, I see what you mean.
    In previous systems I worked on (not on the web stuff, I worked on the backend stuff) there was some session management in the web code that persisted the loaded data for the duration of the session.  Some fancy footwork was involved to handle session timeouts, I believe, but I don't really know what they did.

    Still, typed datasets are easy to create in the IDE and can be used as the 'transport' for data from the web page to the database.

    Perhaps some 9er out there has the perfect answer?


    Herbie

  • User profile image
    figuerres

    W3bbo wrote:
    I'll be taking on a medium-sized web application within the next few days (and underbid for the project, oh how I hate negociations, BTW this was a real-life thing, nothing involving Guru or GetAFreelancer)

    Anyway a lot of it will involve a lot of your standard CRUD operations, but I've been stung before and I don't want to have to write a load of sprocs for each fairly standard operation, then a bunch of simple data-holding classes (that have no methods).

    I'm not keen on ORM classes because it seems a kludge. Whilst you can give them methods that interact with the database it gets complicated when dealing with relationships.

    From what I've read, the strongly-typed DataSets look ideal, but they're more for desktop applications and not webapps.

    Any recommendations?


    a few things to think about:

    1) CSLA for .Net
     -- you have to learn about it but it will do a *LOT* to move you into the logic of the business once you get going.
    2) CodeSmith with or without CSLA
    -- they have some very slick templates that will sspew out dozens of sql procs for you based on the db schema; there are also CSLA tempates that you can use after the sql tempates to build a fairly large framework by just running the templates.

    3)  LINQ / DLINQ
      ok it's new and you have to wrap your head around it but I am staring to really dig how it woks,  just go to Scott Guthries blog
    and follow his 8 part primer and see what you think.

    -er make that 9 parts now Smiley
    http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx

  • User profile image
    ZippyV

    For generating sprocs you can use my l33t app: SQLgenerator. I posted it somewhere in Techoff.

  • User profile image
    W3bbo

    Dr Herbie wrote:
    Ah, I see what you mean.
    In previous systems I worked on (not on the web stuff, I worked on the backend stuff) there was some session management in the web code that persisted the loaded data for the duration of the session.  Some fancy footwork was involved to handle session timeouts, I believe, but I don't really know what they did.

    Still, typed datasets are easy to create in the IDE and can be used as the 'transport' for data from the web page to the database.

    Perhaps some 9er out there has the perfect answer?


    Using ASP.NET's Session state would be fine if it were a small-scale intranet app with a handful of users. But this is a fairly large internet app, so using Session state to store any actual data would eat RAM.

  • User profile image
    littleguru

    W3bbo wrote:
    
    Dr Herbie wrote:
    Ah, I see what you mean.
    In previous systems I worked on (not on the web stuff, I worked on the backend stuff) there was some session management in the web code that persisted the loaded data for the duration of the session.  Some fancy footwork was involved to handle session timeouts, I believe, but I don't really know what they did.

    Still, typed datasets are easy to create in the IDE and can be used as the 'transport' for data from the web page to the database.

    Perhaps some 9er out there has the perfect answer?


    Using ASP.NET's Session state would be fine if it were a small-scale intranet app with a handful of users. But this is a fairly large internet app, so using Session state to store any actual data would eat RAM.


    redirect the session into a database...

  • User profile image
    irascian

    As well as CSLA (which some regard as being a little too obsessed with being OO, at the cost of practicality) you might want to look at LLBLGen:

    http://www.llblgen.com/defaultgeneric.aspx

  • User profile image
    littleguru

    mine, mine, mine *jumping jumping jumping* Expressionless how could i ever...

  • User profile image
    littleguru

    figuerres wrote:


    What I like about Linq to SQL is how they added stuff to the compiler and even the .NET Framework just to make it work... I even requested some of them earlier. Imagine what I got: by design Wink

    How rapily design changes and wonder happen after I had already figured out another way - hah!

  • User profile image
    W3bbo

    littleguru wrote:
    redirect the session into a database...


    I hope you're aware of the irony of storing data cached from a database (for performance) inside another database.

  • User profile image
    JChung2006

    W3bbo wrote:
    
    littleguru wrote:
    redirect the session into a database...


    I hope you're aware of the irony of storing data cached from a database (for performance) inside another database.

    It makes sense if your application and database servers are behind a firewall but your cache server isn't.  That's not an atypical deployment scenario for Web applications that must comply with SOX, PCI/CISP, or other network security requirements.

  • User profile image
    W3bbo

    JChung2006 wrote:
    It makes sense if your application and database servers are behind a firewall but your cache server isn't.  That's not an atypical deployment scenario for Web applications that must comply with SOX or PCI/CISP requirements.


    Ah, well this is for a standalone server which is both an IIS and SQL box.

  • User profile image
    PerfectPhase

    W3bbo wrote:
    
    littleguru wrote:
    redirect the session into a database...


    I hope you're aware of the irony of storing data cached from a database (for performance) inside another database.


    I see no issue with this if it is less costly to store and then get the data out of the second database than to compute from scratch from the first.

  • User profile image
    Chadk

    Opf3 is the best that ever happend in my life.

  • User profile image
    Dr Herbie

    figuerres wrote:
    

    a few things to think about:

    1) CSLA for .Net
     -- you have to learn about it but it will do a *LOT* to move you into the logic of the business once you get going.
    2) CodeSmith with or without CSLA
    -- they have some very slick templates that will sspew out dozens of sql procs for you based on the db schema; there are also CSLA tempates that you can use after the sql tempates to build a fairly large framework by just running the templates.

    3)  LINQ / DLINQ
      ok it's new and you have to wrap your head around it but I am staring to really dig how it woks,  just go to Scott Guthries blog
    and follow his 8 part primer and see what you think.

    -er make that 9 parts now Smiley
    http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx


    CSLA is probably overkill for a simple CRUD framework, but it's a great framework generally (worth investigating even if you just steal ideas for your own code). Once you've learnt it you can use it over and over -- but I think you're probably in a bit of a rush (having underbid the price).

    CodSmith could be what you're looking for, but you're going to have to either use someone else's templates (which of course won't quite do what you want), tweak someone else's template, or develop your own. Which ever way, it's going to take a little investment.
    Codesmith's editor is not free (as I recall), but the templates are just text files so you can edit in notepad or whatever.  I renamed the templated to ASP and edited in VS to get some sort of syntax highlighting, but testing is a bit of a PITA.

    Herbie


    PS: Don't forget to let us know what you ended up using.

  • User profile image
    Rossj

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.