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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:48:40+00:00 2026-06-02T03:48:40+00:00

Here’s my current set-up: Public Interface IDatabase Function CreateParameter(name as String, dbType as <dbTypeEnumeration>)

  • 0

Here’s my current set-up:

Public Interface IDatabase
   Function CreateParameter(name as String, dbType as <dbTypeEnumeration>)
End Interface

Public Class OracleDatabaseRepository
    Implements IDatabase
    Public Function CreateParameter(ByVal name As String, ByVal dbtype As <dbTypeEnumeration>) As Object
    End Function
End Class

Public Class SQLServerRepository
    Implements IDatabase
    Public Function CreateParameter(ByVal name As String, ByVal dbtype As <dbTypeEnumeration>) As Object
    End Function
End Class

Public Class DatabaseService
    Private _rep As IDatabase
    Sub New(ByRef rep As IDatabase)
        _rep = rep
    End Sub
    Public Function CreateParameter(ByVal name As String, ByRef dbtype As <dbTypeEnumeration>) As Object
       _rep.CreateParameter(name, dbtype)
    End Function
End Class

The problem here is what exactly is dbTypeEnumeration. In the example above, it’s simply a placeholder to what my problem is. Since we use both Oracle and SQL Server databases, the DbTypes are different depending on the database being used. For Oracle, the OracleClient object has its own OracleDbType enumeration with types. SQL Server also has its own enumeration.

My question is: is it possible to show those database-specific enumerations depending on which repository is injected into the DatabaseService constructor? If not, what’s the best way to go about this? I want to separate the two databases, share logic, and allow for future development, ala the interface as a code contract for that development.

  • 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-06-02T03:48:42+00:00Added an answer on June 2, 2026 at 3:48 am

    Repository implementation correctness asside, I’d change the level of DbType abstraction.

    This interface is db agnostic.

    Public Interface IDatabase
        Function CreateParameter(ByVal name As String, ByVal type As Type) As Object
    End Interface
    

    The db constrained implementation should be in your concrete Repository itself. How else would you want to keep it generic but still differ between the two types?

    Public Class SqlServerRepo : Implements IDatabase
    
        Private Shared typeLookup As Dictionary(Of Type, Data.SqlDbType) = New Dictionary(Of Type, SqlDbType)
    
        Shared Sub New()
           (...Fill the dict according to your specification ...)
        End Sub
    
        Public Function CreateParameter(name As String, type As Type) As Object Implements IDatabase.CreateParameter
            Dim concreteDbType = typeLookup(type)
            (.. your parameter creation here ..)
        End Function
    End Class
    
    Public Class OracleServerRepo : Implements IDatabase
    
        Private Shared typeLookup As Dictionary(Of Type, OracleType) = New Dictionary(Of Type, OracleType)
    
        Shared Sub New()
            (...Fill the dict according to your specification ...)
        End Sub
    
        Public Function CreateParameter(name As String, type As Type) As Object Implements IDatabase.CreateParameter
            Dim concreteDbType = typeLookup(type)
             (.. your parameter creation here ..)
        End Function
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here is the code: Function getData(ByVal id As String) Dim reader As SqlClient.SqlDataReader Dim
here's my code private void make_Book(int x, int y, string name) { #region Creating
Here is a complete example. I want to forbid using A::set from objects casted
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
Here's my scenario: <!-- Normal Control --> <div class=required> <label for=address1>Address line 1</label> <input
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is what I am trying to achieve in PHP: I have this string:
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here is a snippet of my xaml: <ComboBox x:Name=cbo1 Width=100 SelectedValue=200> <ComboBoxItem Name=n1>100</ComboBoxItem> <ComboBoxItem

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.