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

Add Support for money Store Type in Data Annotations #2747

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

dsum27
Copy link
Contributor

@dsum27 dsum27 commented Dec 18, 2024

Description

This pull request adds functionality to handle the money store type when generating data annotations for entity properties. The change ensures that money-typed columns in the database are correctly represented in the code with [Column(TypeName = "money")].

Changes Made

  • Updated logic to check for the money store type when useDecimalDataAnnotation is enabled.
  • Added an additional else if block to append the appropriate [Column] attribute for properties with money type.

Code Example

if (property.StoreType == "decimal" && useDecimalDataAnnotation)
{
    Sb.AppendLine($"[Column(\"{property.Name}\", TypeName = \"{property.StoreType}({property.Precision},{property.Scale})\")]");
}
else if (property.StoreType == "money" && useDecimalDataAnnotation)
{
    Sb.AppendLine($"[Column(\"{property.Name}\", TypeName = \"{property.StoreType}\")]");
}
else
{
    if (!string.IsNullOrEmpty(propertyNameAndAttribute.Item2))
    {
        Sb.AppendLine(propertyNameAndAttribute.Item2);
    }
}

Why This Change is Needed

  • Improves support for database schemas that use money columns.
  • Ensures that generated entity classes correctly reflect database column types, enhancing accuracy and maintainability.

Testing

  • Verified that properties with StoreType = "money" generate [Column(TypeName = "money")] annotations when useDecimalDataAnnotation is enabled.
  • Confirmed no regressions for other store types (decimal, etc.).

Impact

  • This change is backward compatible and does not affect existing functionality for other store types.

Related Issues

If applicable, reference issue numbers or related discussions:

@ErikEJ
Copy link
Owner

ErikEJ commented Dec 19, 2024

Looks good, how did you verify the change works as expected?

@dsum27
Copy link
Contributor Author

dsum27 commented Dec 19, 2024

@ErikEJ I verified the change by running the project locally in a WSL environment on Windows to ensure it functions as expected.

@ErikEJ
Copy link
Owner

ErikEJ commented Dec 19, 2024

Sorry, which "project" - one way to verify is to launch the efcpt.8 Console app, adjust the command line (connection string) and the config to add changes that triggers your new feature.

@dsum27
Copy link
Contributor Author

dsum27 commented Dec 19, 2024

Yes, sorry. I ran the cfcpt.8 console app with adjustments to the args with my connection string and config values.

@ErikEJ
Copy link
Owner

ErikEJ commented Dec 19, 2024

@dsum27 Cool, thanks for confirming and thanks for your contribution!

@ErikEJ ErikEJ merged commit efe9a32 into ErikEJ:master Dec 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants