Data Layer Class Generator

I can’t remember where I found it, but thisĀ SQL script will generate a Dapper compatible class file for theĀ table you specify.

Also this script is handy to use in the business / mapping layer of you application:

SELECT SCHEMA_NAME(SCHEMA_ID) AS [Schema], 
SO.name AS [ObjectName],
REPLACE(p.name, '@', 'rec.') + ',' as prop,
SO.Type_Desc AS [ObjectType (UDF/SP)],
P.parameter_id AS [ParameterID],
P.name AS [ParameterName],
TYPE_NAME(P.user_type_id) AS [ParameterDataType],
P.max_length AS [ParameterMaxBytes],
P.is_output AS [IsOutPutParameter]
FROM sys.objects AS SO
INNER JOIN sys.parameters AS P 
ON SO.OBJECT_ID = P.OBJECT_ID
WHERE SO.OBJECT_ID IN ( SELECT OBJECT_ID 
FROM sys.objects
WHERE TYPE IN ('P','FN'))
AND SO.name = 'YourProcedureSave'
ORDER BY [Schema], SO.name, P.parameter_id