Prepare DTO layer by using below script
DECLARE @CurID INT, @MaxID INT
Declare @sql nvarchar(MAX)
Declare @TmpTable table (ID int Identity(1,1), c_Column_name varchar(500),c_Data_type varchar(50),c_character_Maximum_length nvarchar(50))
Insert into @TmpTable (c_Column_name,c_Data_type,c_character_Maximum_length)
SELECT COLUMN_NAME ,DATA_TYPE ,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TT_M_User' --Table Name
ORDER BY ORDINAL_POSITION ASC;
set @CurID = 1
set @sql=''
SELECT @MaxID=Max(ID) FROM @TmpTable WHILE @MaxID >=@CurID BEGIN -- Logic to be performed
select @sql = @sql + char(13)+ ' public ' +
case c_Data_type
when 'varchar' then ' string '
when 'nvarchar' then ' string '
when 'bit' then ' bool '
when 'datetime' then ' DateTime '
when 'binary' then ' Byte[] '
else c_Data_type end + ' ' + c_Column_Name + ' {get;set;} '
from @TmpTable where ID=@CurID
set @CurID = @CurID +1
END
print @sql
Comments
Good job Jayesh Lolariya