MoonStorm / FastCrud

fast .NET ORM for strongly typed people
MIT License
506 stars 128 forks source link

Insert Fails when Primary Key column set property is private #133

Closed DavidJBerman closed 2 years ago

DavidJBerman commented 6 years ago

Hi, great library, thanks for sharing it with the community! I found a behavior that I think is a defect and I don't want to submit a pull request because some of this code is pretty complicated (to me!).

Use case:

Steps to Reproduce: [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public Guid PasswordResetTokenId { get; private set; } // Value set in constructor

Insert operation: Conn.Connection.Insert(token);

Expected Behavior: Object will be inserted in database.

Actual Behavior: Exception is thrown because you can't insert NULL value for PasswordResetTokenId into the database row.

Comments:

Impact:

MoonStorm commented 2 years ago

We recommend keeping the properties as public. These are data entities, they should not contain any kind of logic in them (including initialization logic).