Is there any way to programmatically map a .NET type (such as typeof(int)) into its corresponding SqlDbType (such as SqlDbType.Int)?
3 Answers
Have you looked into The Entity Framework? This will do all of the mappings for you.
4 Comments
Frank Hale
+1 - I was also thinking the same thing or perhaps LINQ to SQL or another ORM.
isekaijin
Excuse my ignorance. Do the Entity Framework or LINQ to SQL support stored procedures?
Harsh Baid
ya it does support stored procedures also
Hogan
It does support SPs but from my experience it is a bit like putting a tutu on a pig.
See Also:
1 Comment
isekaijin
I wanted a function that performed those mappings, instead of me having to manually implement them. Thanks, anyway.
DbCommands and the creation of itsDbParameters respectively, hiding the database-specific details from the rest of the application. And also, I don't want to map types manually; at least, not for the case of Sql Server.