Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Column type to the column property #35

Closed
amalsharief opened this issue Sep 5, 2021 · 2 comments · Fixed by #66
Closed

Adding Column type to the column property #35

amalsharief opened this issue Sep 5, 2021 · 2 comments · Fixed by #66
Labels
enhancement New feature or request

Comments

@amalsharief
Copy link

amalsharief commented Sep 5, 2021

Could you kindly add the table column type ?
Thank you in advance.

Abdoessalam

My suggestion is :
To add Column type property - the column attribute in EF core is as follows :
Column Attribute: [Column (string name, Properties:[Order = int],[TypeName = string])
ex
[Column("DoB", Order = 1, TypeName="DateTime2")]

The suggested steps to add it :

a- open Craftsman\Models\EntityProperty.cs file, append the following property:

    public string ColumnType { get; set; }

b- open Craftsman\Builders\EntityBuilder.cs file and replace the following:

     if (!string.IsNullOrEmpty(entityProperty.ColumnName))                         
        attributeString += @$"        [Column(""{entityProperty.ColumnName}"",TypeName=""{entityProperty.ColumnType}"")]{Environment.NewLine}";              
    
    with the following:

     if (!string.IsNullOrEmpty(entityProperty.ColumnName))
        {
            if (!string.IsNullOrEmpty(entityProperty.ColumnType))
                attributeString += @$"        [Column(""{entityProperty.ColumnName}"",TypeName=""{entityProperty.ColumnType}"")]{Environment.NewLine}";
            else
                attributeString += @$"        [Column(""{entityProperty.ColumnName}"")]{Environment.NewLine}";
        }
@amalsharief amalsharief added the enhancement New feature or request label Sep 5, 2021
@pdevito3
Copy link
Owner

pdevito3 commented Sep 5, 2021

Sounds reasonable. I'll put it in my backlog

@pdevito3
Copy link
Owner

pdevito3 commented Sep 5, 2021

Btw, if you're up for a PR it would be more than welcomed. Not sure how soon I'll get to this, but it should be a pretty low lift and good first ticket!

  • new property on EntityProperty
  • updating the attribute builder in the EntityBuilder class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants