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

  • Home
  • SEARCH
  • 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 185203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:25:43+00:00 2026-05-11T15:25:43+00:00

I have some legacy code that I’m rewriting using SubSonic to help the future

  • 0

I have some legacy code that I’m rewriting using SubSonic to help the future maintainers. For the most part it’s been relatively simple, as everything makes a stored procedure call. But now I’m having some difficulty with some tightly-coupled ADO.NET code.

The code depends on the SqlDataAdapter to decide when to call an INSERT or UPDATE stored proc, which I understand. How can I rewrite this code in a SubSonic way?

public void SaveInvoice(InvoiceItems invoiceItems) {     // extraneous code removed     // invoiceItems is a dataset      cmd.CommandType = CommandType.StoredProcedure;     cmd.CommandText = 'InvoiceItem_INSERT';     cmd.Connection = conn;      updateCmd.CommandType = CommandType.StoredProcedure;     updateCmd.CommandText = 'InvoiceItem_UPDATE';     updateCmd.Connection = conn;      SqlCommandBuilder.DeriveParameters(cmd);     SqlCommandBuilder.DeriveParameters(updateCmd);      adapter.InsertCommand = cmd;     adapter.UpdateCommand = updateCmd;      adapter.Update(invoiceItems._InvoiceItemTable); } 

I’m new to SubSonic, so any help is appreciated. All helpful answers will be gleefully upvoted.

  • 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. 2026-05-11T15:25:44+00:00Added an answer on May 11, 2026 at 3:25 pm

    There isn’t going to be an exact representation of that kind of code using SubSonic because the automagic insert/update is done specifically by the SqlDataAdapter.Update() method. If there somehow is, buried somewhere within the SubSonic namespace, I would also like to know how to use it!

    If you’re dealing with one table (e.g. InvoiceItems), you can do the test yourself (this uses SubSonic’s automatically generated active record implementation):

    int key = InvoiceItems.ID; // not sure what your primary key identifier is called InvoiceItem item = new InvoiceItem(key); if (item != null) {     SPs.InvoiceItem_UPDATE(param1, param2, etc).Execute(); } else  {     SPs.InvoiceItem_INSERT(param1, param2, etc).Execute(); } 

    Hopefully this gets you started.

    As a totally unrelated sidenote, don’t rely on the DeepSave() method to try to save across multiple tables, because it is not implemented. I found that out the hard way…

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

Sidebar

Ask A Question

Stats

  • Questions 178k
  • Answers 178k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You have declared the free function MyLog& operator<<(MyLog& l,char* msg)… May 12, 2026 at 3:42 pm
  • Editorial Team
    Editorial Team added an answer If aTable.date contains millisenconds and bTable.date does not, to compare… May 12, 2026 at 3:42 pm
  • Editorial Team
    Editorial Team added an answer Html/xml should not be processed with regular expressions, it is… May 12, 2026 at 3:42 pm

Related Questions

I have some legacy code that I'm rewriting using SubSonic to help the future
I have some legacy C code that I recently compiled on Linux. On the
I have some legacy code that provides a list of the available COM ports
I have some Visual C++ code that receives a pointer to a buffer with
For the past year I've been working on some legacy code that was written

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.