Re: Making a generic Parameter class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: SimonH (none_at_hotmail.com)
Date: 01/11/05


Date: Tue, 11 Jan 2005 09:09:59 -0800

Nick,

Thanks for your reply.

I've used the adapter and abstract factory patterns before.

What I need to know is if there is already a generic implementation class
for the IdbParameter interface that I can use?

Is the case basically that I need to make my own simple parameter implementation?
I'd rather not if there was already a simple implementation already as it
make my datalayer more complicated.

If I have to implement though, I'll just have to :-)

Thanks for your help

Kindest Regards

> SqlParameter is an implementation of an 'Adapter' pattern. This
> allows things like DataAdapter and DataReader to be able to use
> generic methods for using these objects without concern for which
> database lies underneath it. If you have a database (that is not
> either SQL Server or Oracle) that you want to access, simply creating
> objects that meets the same interface (MarshalByRefObject,
> IDbDataParameter, IDataParameter, ICloneable) will allow your methods
> to be used by the higher-level database objects.
>
> In other words, .Net already does this for you.
>
> What .Net doesn't do is provide you with an abstract factory. You can
> easily write one that returns an object of type IDbDataParameter when
> you want to create a new parameter object. Then you can use your
> factory to create generic objects, and in fact, can use these objects
> as generic ones (cross db) without knowing if the factory is
> connecting you to SQL Server objects, Oracle objects, or another set
> of Adapter objects.
>
> Please read up on the Abstract Factory pattern.
>
> http://www.dofactory.com/Patterns/PatternAbstract.aspx
>
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a
> programmer helping programmers.
> --
> "SimonH" <none@hotmail.com> wrote in message
> news:9347632410525392812500@news.microsoft.com...
>> Hi all,
>>
>> I would like to make a generic set of methods that could be called
>>
> regardless
>
>> of the database behind the scenes.
>>
>> One of the methods I would like would take a string sql statement and
>> an array of DataParameter objects.
>>
>> The problem i have is there doesnt seem to be a generic DataParameter
>>
> class
>
>> that I can instantiate. There only seems to be specific
>> implementations
>>
> like
>
>> SQLParamater and so on.
>>
>> The is an interface called IDataParameter or something to that
>> effect, but of course I can't instantiate an interface.
>>
>> I need to be able to work with a non-specific parameter object.
>>
>> Does anyone know what I could do?
>>
>> Many thanks all
>>
>> Kindest Regards
>>



Relevant Pages

  • Re: Making a generic Parameter class
    ... SqlParameter is an implementation of an 'Adapter' pattern. ... using these objects without concern for which database lies underneath it. ... What .Net doesn't do is provide you with an abstract factory. ...
    (microsoft.public.dotnet.general)
  • Re: Making a generic Parameter class
    ... What new database system do you want to abstract? ... > for the IdbParameter interface that I can use? ... >> What .Net doesn't do is provide you with an abstract factory. ... >> programmer helping programmers. ...
    (microsoft.public.dotnet.general)
  • Re: MVPs: static methods in interfaces. (REDEFINED)
    ... this static method is public and therfore should be publicly known ... >> code to define a behavior (the interface) and another body of code to ... >> Abstract Factory pattern describes. ... >> programmer helping programmers. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Separation of API and implementation
    ... I'm missing something or an Abstract Factory could help? ... I have an API defined in one plugin, ... interface X { ... implementation of Y, say YImpl. ...
    (comp.object)
  • Re: Separation of API and implementation
    ... An abstract factory can help, as long as it keeps track of which Xs are ... from package A and which ones are from package B so it knows how to ... The basic problem is with the OPs interface: ... The interface above is a lie, because it says that every X can handle ...
    (comp.object)