Is there any way to programmatically map a .NET type (such a开发者_如何学Pythons typeof(int)
) into its corresponding SqlDbType (such as SqlDbType.Int
)?
Have you looked into The Entity Framework? This will do all of the mappings for you.
Not that I know of, tehre is no exposure of whatever method is used internally. Your best bet it your own extension method / mapping repository that uses a switch statement or a hashtable.
See Also:
SQL Server Data Type Mappings (ADO.NET)
精彩评论