Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Database-Table-Wrapper Class Code Generator

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Tue, Oct 16, 2012, 4:53 PM


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 ('PropertyActivity', 'PropertyContact2')
    )
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.