Skip to content

Enum tables PostgreSQL #858

@QifiMicke

Description

@QifiMicke

I have a table status

CREATE  TABLE  types.status
(id int PRIMARY KEY,
name varchar(10))

INSERT INTO "types"."Status" (id, "name")
VALUES(1, 'Todo'), (2, 'InProgress'), (3, 'Done');

in tt file

 new EnumerationSettings
        {
            Name       = "Status",
            Table      = "types.status",
            NameField  = "id",
            ValueField = "name"
        },

I have also added config into

Settings.AddEnumDefinitions = delegate(List<EnumDefinition> enumDefinitions)

enumDefinitions.Add(new EnumDefinition {
    Schema = Settings.DefaultSchema,
    Table = "Request", 
    Column = "statusId", 
    EnumType = "types_Status" });

Keep in mind that I have two schemas
types
public

Public is the schema that I want to use for these.

reverse poco does not create an enum value object when saving tt file

 public partial class types_Status
 {
     public int Id { get; set; } // id (Primary key)
     public string Name { get; set; } // name (length: 20)
}

for request

public partial class Request
{
    public int Id { get; set; } // id (Primary key)
    public string Name { get; set; } // name (length: 255)
    public string CdsId { get; set; } // cdsId (length: 10)
    public int? VehiclePlatformId { get; set; } // vehiclePlatformId
    public int? VehicleProjectId { get; set; } // vehicleProjectId
    public types_Status? StatusId { get; set; } // statusId
    public int? SupplierCompanyId { get; set; } // supplierCompanyId
    public string CreatedBy { get; set; } // createdBy (length: 10)
    public DateTime CreatedDate { get; set; } // createdDate
    public string UpdatedBy { get; set; } // updatedBy (length: 10)
    public DateTime UpdatedDate { get; set; } // updatedDate
}

expected

public Enum types_Status
 {
     Todo = 1
     InProgress = 2
     Done = 3
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions