Entity property key values
The Slothful CRUD library allows you to customize how key values for entity properties are generated by implementing the IEntityPropertyKeyValueProvider<TEntity>
interface.
Default Implementation
By default, the EntityPropertyKeyValueProvider
class generates key values for Guid
types. If you need support for other key types, you must provide your own implementation.
Customizing Key Value Generation
To customize key value generation, you can create your own implementation of the IEntityPropertyKeyValueProvider
public interface IEntityPropertyKeyValueProvider<TEntity> where TEntity : class, ISlothfulEntity
{
object GetNextValue(EntityConfiguration configuration);
}
Customizing the key value provider allows you to:
- Support Different Key Types: Ensure that your application can generate key values for various property types, not just
Guid
. - Implement Custom Logic: Apply specific business rules or algorithms to generate unique key values.
- Ensure Consistency: Maintain consistent key value generation across your application, adhering to your data integrity requirements.