G
Guest
Hi,
I am creating my own data access layer (I know I am re-inventing the wheel
but I like the challenge).
At the moment I am able to pass in a HashTable with the key and parameter
value and I use the key to get the SqlDbType from a config file. From there
I set up the parameters required for the backend Sp's.
The trouble is, I am left with something like this:
foreach(DictionaryEntry de in hashTable)
{
string key = de.Key;
object val = de.Value; //I don't yet know the type
//Create the parameter (called param) and assign the name and type here
Param.Value = val;
//Other stuff here
}
Is it okay to pass an object as the value, or should I cast it to the
correct type first? Is there any significant overhead here?
I thought about getting the type from the SqlParameter once I had set it up
but that would give me an SqlDbType rather than a System.Type.
Can anyone suggest a way to cast this (other than retrieve them from another
config file), or is it okay to pass the value as an object?
Any help is always appreciated.
I am creating my own data access layer (I know I am re-inventing the wheel
but I like the challenge).
At the moment I am able to pass in a HashTable with the key and parameter
value and I use the key to get the SqlDbType from a config file. From there
I set up the parameters required for the backend Sp's.
The trouble is, I am left with something like this:
foreach(DictionaryEntry de in hashTable)
{
string key = de.Key;
object val = de.Value; //I don't yet know the type
//Create the parameter (called param) and assign the name and type here
Param.Value = val;
//Other stuff here
}
Is it okay to pass an object as the value, or should I cast it to the
correct type first? Is there any significant overhead here?
I thought about getting the type from the SqlParameter once I had set it up
but that would give me an SqlDbType rather than a System.Type.
Can anyone suggest a way to cast this (other than retrieve them from another
config file), or is it okay to pass the value as an object?
Any help is always appreciated.