Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 696615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:04:54+00:00 2026-05-14T03:04:54+00:00

Initially I had a method in our DL that would take in the object

  • 0

Initially I had a method in our DL that would take in the object it’s updating like so:

internal void UpdateCash(Cash Cash)
{
    using (OurCustomDbConnection conn = CreateConnection("UpdateCash"))
    {
        conn.CommandText = @"update Cash
                             set    captureID = @captureID,
                                    ac_code = @acCode,
                                    captureDate = @captureDate,
                                    errmsg = @errorMessage,
                                    isDebit = @isDebit,
                                    SourceInfoID = @sourceInfoID,
                                    PayPalTransactionInfoID = @payPalTransactionInfoID,
                                    CreditCardTransactionInfoID = @CreditCardTransactionInfoID
                                 where id = @cashID";

        conn.AddParam("@captureID", cash.CaptureID);
        conn.AddParam("@acCode", cash.ActionCode);
        conn.AddParam("@captureDate", cash.CaptureDate);
        conn.AddParam("@errorMessage", cash.ErrorMessage);
        conn.AddParam("@isDebit", cyberCash.IsDebit);
        conn.AddParam("@PayPalTransactionInfoID", cash.PayPalTransactionInfoID);
        conn.AddParam("@CreditCardTransactionInfoID", cash.CreditCardTransactionInfoID);
        conn.AddParam("@sourceInfoID", cash.SourceInfoID);
        conn.AddParam("@cashID", cash.Id);

        conn.ExecuteNonQuery();
    }
}

My boss felt that creating an object every time just to update one or two fields is overkill. But I had a couple places in code using this. He recommended using just UpdateCash and sending in the ID for CAsh and field I want to update. Well the problem is I have 2 places in code using my original method. And those 2 places are updating 2 completely different fields in the Cash table. Before I was just able to get the existing Cash record and shove it into a Cash object, then update the properties I wanted to be updated in the DB, then send back the cash object to my method above.

I need some advice on what to do here. I have 2 methods and they have the same signature. I’m not quite sure what to rename these because both are updating 2 completely different fields in the Cash table:

internal void UpdateCash(int cashID, int paypalCaptureID)
{
    using (OurCustomDbConnection conn = CreateConnection("UpdateCash"))
    {
        conn.CommandText = @"update Cash
                             set    CaptureID = @paypalCaptureID
                  where id = @cashID";

        conn.AddParam("@captureID", paypalCaptureID);

        conn.ExecuteNonQuery();
    }
}

internal void UpdateCash(int cashID, int PayPalTransactionInfoID)
{
    using (OurCustomDbConnection conn = CreateConnection("UpdateCash"))
    {
        conn.CommandText = @"update Cash
                             set    PaymentSourceID = @PayPalTransactionInfoID
                  where id = @cashID";

        conn.AddParam("@PayPalTransactionInfoID", PayPalTransactionInfoID);

        conn.ExecuteNonQuery();
    }
}

So I thought hmm, maybe change the names to these so that they are now unique and somewhat explain what field its updating:

UpdateCashOrderID

UpdateCashTransactionInfoID

ok but that’s not really very good names. And I can’t go too generic, for example:

UpdateCashTransaction(int cashID, paypalTransactionID)

What if we have different types of transactionIDs that the cash record holds besides just the paypalTransactionInfoID? such as the creditCardInfoID? Then what? Transaction doesn’t tell me what kind. And furthermore what if you’re updating 2 fields so you have 2 params next to the cashID param:

UpdateCashTransaction(int cashID, paypalTransactionID, someOtherFieldIWantToUpdate)

see my frustration? what’s the best way to handle this is my boss doesn’t like my first route?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:04:54+00:00Added an answer on May 14, 2026 at 3:04 am

    My boss felt that creating an object every time just to update one or two fields is overkill.

    He would be right, if you have to create the object every time. The correct response to this is that you should already be using these business objects throughout your app. You don’t create a new Cash object. You pass it the Cash object you already have to be saved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function I've written that was initially supposed to take a string
I recently wrote a program that used a simple producer/consumer pattern. It initially had
Initially I had written this query using LINQ-to-SQL var result = from w in
I have a modal popup that initially shows some content but expands a div
Our team is developing a rather big ASP.NET web project which initially started in
Hi I've got a DIV section that has only its title visible initially. What
We're currently trying to integrate existing classic ASP pages into our new method of
I'm using entity framework 4. I have a stored procedure that just updates one
Initially this demo application I'm working on had just one page with a simple
I had my NHibernate session management setup like follows: protected MvcApplication() { BeginRequest +=

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.