DbLayout
with DataTypes as ( select TSqlType = 'bigint', CsType = 'long' union select 'bit', 'bool' union select '%char%', 'string' union select '%date%', 'DateTime' union select 'decimal%', 'decimal' union select 'float%', 'decimal' union select 'int', 'int' union select 'money', 'decimal' union select '%text%', 'string' union select 'smallint', 'short' union select 'uniqueidentifier','Guid' ) ,Fields as ( select CsType = t.CsType + case when d.IsNullable = 1 and t.CsType <> 'string' then '?' else '' end ,d.* from dbo.DbLayout d left join DataTypes t on d.DataType like t.TSqlType where 1=1 and TableName in ('Order', 'Invoice') ) select distinct TableName, Sort2 = 10, Sort3 = 10, code = 'public class ' + TableName + 'View' from Fields union select distinct TableName, 20, 10, '{' from Fields union select TableName, 30, ColumnOrder, code = ' public ' + CsType + ' ' + ColumnName + ' { get; set; }' from Fields union select distinct TableName, 40, 10, '}' from Fields order by TableName, Sort2, Sort3
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.