CodeSmith Community
Your Code. Your Way. Faster!

How To Do Simple Tasks

Latest post 02-12-2008 11:59 AM by bgjohnso. 2 replies.
  • 02-12-2008 9:35 AM

    • Skirvir
    • Not Ranked
    • Joined on 02-12-2008
    • Posts 2
    • Points 40

    How To Do Simple Tasks

    I've continuously been plagued with wasting alot of time figuring out how to do the most basic things such as:

    How do I write a simple UPDATE sql statement using netTiers, obviously the point of the DAL is to hide the raw SQL, so although I can write that extremely quickly I've been trying to see how to use *Query or SqlBuilders etc, to accomplish the same thing so that everything is strongly typed and safe. However I can't figure it out.

    If anyone could give me pointers on how I can make a general update statement with a basic filter, using the netTier objects, I'd be greatful and if this exists in some documentation somewhere, please point me in the right direction.

     Thanks

    • Post Points: 5
  • 02-12-2008 10:02 AM In reply to

    • Skirvir
    • Not Ranked
    • Joined on 02-12-2008
    • Posts 2
    • Points 40

    Re: How To Do Simple Tasks

    What I've done in the time being is the following:

     I've used *ParameterBuilder object, to handle my filtering information, then used DataRepository.*Provider.Find(*ParameterBuilder.GetParameters()) to return a list of my records.

    Then I loop over those records and update the column(s) I need to update and finally pass each one into DataRepository.*Provider.Update().

    While this works, it seems very inefficient when ideally, there should be some way of sending a parameterized SQL statement straight to the DB so the statement can be executed one time agains the db server. However, the way I've done it as explained above, requires X number of wasted trips to the the db server and is also a chore to setup and write, compared to the very simple raw SQL statement that would accomplish the same thing.

    I feel I must be missing something because doing something this simple in this way seems overly complicated and completely inefficient.

    • Post Points: 35
  • 02-12-2008 11:59 AM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WA
    • Posts 764
    • Points 22,530

    Re: How To Do Simple Tasks

    NetTiers is designed around entities, and as such all the operations are designed to work on a single record at a time.  There is really no mechanism to do what you want within netTiers.  You could write a custom stored procedure that would do the update for you and have it attached to the appropriate entity provider.

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------

    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems