CRATE PROCEDURE [dbo].[Sp_GetClsClass] @TableName VARCHAR(50)
AS
BEGIN
SELECT CHAR(13) + 'private '
+ CASE WHEN a.DATA_TYPE = 'varchar' THEN 'string'
WHEN a.DATA_TYPE = 'numeric' OR a.DATA_TYPE = 'smallint' THEN CASE WHEN a.Numeric_scale != 0 THEN 'double' ELSE 'int' END
WHEN a.DATA_TYPE = 'datetime' THEN 'string'
WHEN a.data_type = 'bit' THEN 'int'
ELSE a.DATA_TYPE
END + ' _' + a.COLUMN_NAME + ';' + CHAR(13) + 'public '
+ CASE WHEN a.DATA_TYPE = 'varchar' THEN 'string'
WHEN a.DATA_TYPE = 'numeric' OR a.DATA_TYPE = 'smallint' THEN CASE WHEN a.Numeric_scale != 0 THEN 'double' ELSE 'int' END
WHEN a.DATA_TYPE = 'datetime' THEN 'string'
WHEN a.data_type = 'bit' THEN 'int'
ELSE a.DATA_TYPE
END + ' ' + a.COLUMN_NAME + CHAR(10) + '{' + CHAR(13)
+ ' get { return _' + a.COLUMN_NAME + ';}' + CHAR(13)
+ ' set { _' + a.COLUMN_NAME + '=value;}' + CHAR(13) + '}'
FROM LandSaleAcc.INFORMATION_SCHEMA.COLUMNS a
WHERE TABLE_NAME = @TableName
END
===================================================================
O/P:=
Sp_GetClsClassNew 'TABLENAME'
======================================================================
private string _CompCode;
public string CompCode
{
get { return _CompCode;}
set { _CompCode=value;}
}
AS
BEGIN
SELECT CHAR(13) + 'private '
+ CASE WHEN a.DATA_TYPE = 'varchar' THEN 'string'
WHEN a.DATA_TYPE = 'numeric' OR a.DATA_TYPE = 'smallint' THEN CASE WHEN a.Numeric_scale != 0 THEN 'double' ELSE 'int' END
WHEN a.DATA_TYPE = 'datetime' THEN 'string'
WHEN a.data_type = 'bit' THEN 'int'
ELSE a.DATA_TYPE
END + ' _' + a.COLUMN_NAME + ';' + CHAR(13) + 'public '
+ CASE WHEN a.DATA_TYPE = 'varchar' THEN 'string'
WHEN a.DATA_TYPE = 'numeric' OR a.DATA_TYPE = 'smallint' THEN CASE WHEN a.Numeric_scale != 0 THEN 'double' ELSE 'int' END
WHEN a.DATA_TYPE = 'datetime' THEN 'string'
WHEN a.data_type = 'bit' THEN 'int'
ELSE a.DATA_TYPE
END + ' ' + a.COLUMN_NAME + CHAR(10) + '{' + CHAR(13)
+ ' get { return _' + a.COLUMN_NAME + ';}' + CHAR(13)
+ ' set { _' + a.COLUMN_NAME + '=value;}' + CHAR(13) + '}'
FROM LandSaleAcc.INFORMATION_SCHEMA.COLUMNS a
WHERE TABLE_NAME = @TableName
END
===================================================================
O/P:=
Sp_GetClsClassNew 'TABLENAME'
======================================================================
private string _CompCode;
public string CompCode
{
get { return _CompCode;}
set { _CompCode=value;}
}
No comments:
Post a Comment