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 options Parameter for Configurable Primary Key and ValueGenerated Behavior #10

Open
william-des opened this issue Sep 15, 2023 · 0 comments

Comments

@william-des
Copy link

Hello 👋,

I've been using this package in my project and have come across a specific need. Currently, the package automatically removes all primary keys when cloning an entity. While this is the desired behavior in most cases, in some scenarios, it would be useful to keep certain primary keys intact.

Proposed Feature:

I propose adding an optional options parameter that would allow the users to configure:

  1. Whether to remove primary keys or not (Boolean).
  2. Whether to remove properties based on their value generation strategy using the ValueGenerated enum.
public class CloneOptions
{
    public bool RemovePrimaryKeys { get; set; } = true;
    public ValueGenerated? RemoveBasedOnValueGenerated { get; set; }
}

Example Usage:

var options = new CloneOptions
{
    RemovePrimaryKeys = false,
    RemoveBasedOnValueGenerated = ValueGenerated.OnAdd
};

var clonedEntity = await context.CloneAsync(options, 123);

Why this feature would be useful:

This feature would make the package more flexible for a wider range of use-cases. Sometimes, not all primary keys should be treated equally, and having this granular control can be extremely beneficial.

If you find this feature useful, I'd be happy to submit a PR to implement it.

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

No branches or pull requests

1 participant