This script will help you to create Auto Implemented public properties.
For this you just need to pass the table name and the Script will create properties for each column available in that Table.
Copy the following code to generate the properties:
For this you just need to pass the table name and the Script will create properties for each column available in that Table.
Copy the following code to generate the properties:
DECLARE @TableName VARCHAR(100)
SET @TableName = 'tblUsers'
--String
SELECT 'public string ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (35, 36, 98, 99,165,167,173,175,231,239,241,231,189)
UNION
-- Int64
SELECT 'public Int64 ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (127)
UNION
-- Int32
SELECT 'public Int32 ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (56)
UNION
-- Int16
SELECT 'public Int16 ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (48, 52)
UNION
--Decimal
SELECT 'public Decimal ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (108, 62, 106, 60,122)
UNION
--Boolean
SELECT 'public Boolean ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (104)
UNION
-- DateTime
SELECT 'public DateTime ' + name + ' { get; set; }'
FROM Sys.COLUMNS WHERE Object_ID = OBJECT_ID(@TableName)
AND System_Type_ID IN (58,61)
0 comments:
Post a Comment