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 5973817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:51:15+00:00 2026-05-22T20:51:15+00:00

I have Business Objects classes that need to know what connection string have to

  • 0

I have Business Objects classes that need to know what connection string have to use.

I call/create those BO from my code passing the connection String to a connString property of the BO, and can be called/created too from framework controls, and this doesn’t allow me set connString property. (I have to call the method with one additional parameter for connectionstring)

I have something like this:

public class MyBOClass{
    public FillMethodX(int ID)
    {
        //Fill the BO with data...
    };
    public FillMethodX(int ID, string connString)
    {
        SetConnString(connString);
        FillMethodX(ID);
    };

    public FillMethodY(int ID)
    {
        //Fill the BO with data...
    };
    public FillMethodY(int ID, string connString)
    {
        SetConnString(connString);
        FillMethodY(ID);
    };
}

Can I avoid to replicate each method with a overload to pass a connString with a best approach? (optional parameter,generics, etc??)

Thanks.

edit: sorry I put “connection string” but really I passing a string that represents a database that my BOs use internally.

  • 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-22T20:51:16+00:00Added an answer on May 22, 2026 at 8:51 pm

    There are many ways you can do this, one of which you mentioned already – optional arguments.

    Another way would be to expose a generic ConnectionString property that returns the current connection string, and then do away with the 1 parameter overload. Callers would be required to pass a connection string, and can just pass MyBOClass.ConnectionString. This may actually be a little clearer to readers of the code who wonder where the connection info comes from in the first place.

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

Sidebar

Related Questions

I have some business objects which use: Web.Configuration.WebConfigurationManager.AppSettings.Item(SomeSetting) Now that I'm breaking those objects
I'm stumped here. I have an observable collection that holds business objects. I have
I have a business layer that has some business objects/POCOs/entities/whatever. I also have some
I have need to use one of two custom file readers classes; one to
I have a heirarchy of classes that get initialized from a database. I am
Business Objects Web Services returns error codes and I have yet to find a
I have a question regarding the integration of business objects developed using Linq To
So, I have a ListBox which is bound to a list of business objects,
I have a business object that compiles into a DLL that handles all calculations
If I have a business object with 50 fields, and I need to populate

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.