TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joe Marcavage
NA
1
2.3k
C#.NET Parameterizing a Generic
Jul 19 2010 11:48 AM
Goal: Genericize the method so I can pass in a database wrapper class that takes a "functions" class as a parameter. The "functions" class has all the connection plumbing, etc. The caller to GetWrapper() has knowledge of what database wrapper to use, but doesn't know what the underlying database architecture is.
Error Message: The type parameter 'T' cannot be used with type arguments.
Is there ever a case when I can do something like the below:
public static T GetWrapper<T>(string provider)
{
T wrap = default(T);
switch (provider)
{
case "System.Data.SqlClient":
wrap = new T<SQLServerFunctions>();
break;
case "System.Data.Odbc":
wrap = new T<PostgresFunctions>();
break;
case "MySql.Data.MySqlClient":
wrap = new T<MySQLFunctions>();
break;
}
return wrap;
}
I'm thinking the answer is "no" but I wanted to ask the experts here. Thanks in advance.
Joe M.
Reply
Answers (
1
)
Framework Required
SAP Remote Function Call