Create C# Model Using Query Postgre SQL

Create C# Model Using Query Postgre SQL

Query :

SELECT 'public',  CASE WHEN data_type='bigint' THEN 'int64' WHEN data_type='integer' THEN 'int' ELSE 'string' END ,column_name,'{get;set;}',data_type

  FROM information_schema.columns

 WHERE table_schema = 'public'

AND table_name   = 'Tbl_M_RegistrationLand'


Output :

public class RegistrationLand

{

    public int LandRegsitrationID { get; set; }

 

    public int KhataNumber { get; set; }


    public string? owner { get; set; }


    public string? khata_type { get; set; }

}




Generate Using View : 


SELECT 'public ',

CASE WHEN format_type(atttypid, atttypmod)='bigint' THEN 'Int64' WHEN format_type(atttypid, atttypmod)='integer' THEN 'int' ELSE 'string' END ,

attname AS column_name ,'{get;set;}'

FROM   pg_attribute

WHERE  attrelid = 'public.vw_applicationDetails'::regclass

ORDER  BY attnum;

Comments

Popular posts from this blog

Uploading Image to Sql Server Image Datatype in asp.net using fileupload Control

Get Running Sum of Query SQL Query