Closed feast107 closed 1 year ago
Can you provide a sample code about what you are trying to achieve please?
In onModelCreating
it will be called like:
modelBuild.Entity<TEntity>.AllPropertiesExcept(new []
{
nameof(TEntity.NotEncryptedProperty),
...
}).IsEncrypted(); //AreEncrypted()...?
AllPropertiesExcept
returns IEnumerable<PropertyBuilder>
for it uses reflection, which makes me cannot use generic-type of PropertyBuilder<TProperty>
.
I'v written a
PropertyBuilder IsEncrypted(this PropertyBuilder builder,StorageFormat storageFormat = StorageFormat.Default)
use the same implement of IsEncrypted<TProperty>
in this repo and it seems work well.
Thanks very much anyway! :satisfied:
I don't mind contributing these codes if u need them, IsEncrypted<TProperty>
seems lonely in the extension. :yum:
Since your method is returning a IEnumerable<PropertyBuilder>
, you can iterate over this collection and call the IsEncrypted()
method for each element:
IEnumerable<PropertyBuilder> encryptedProperties = modelBuilder.Entity<TEntity>.AllPropertiesExcept(new[]
{
nameof(TEntity.NotEncryptedProperty),
// ...
});
foreach (IPropertyBuilder property in encryptedProperties)
{
property.IsEncrypted();
}
I don't think there is a point in doing a AreEncrypted()
method inside the library, but you can still build this extensions for your project if needed.
Is it undecided to provide or may it lead to some unknown error if provided? I have now written a required version in my code. For I need to use reflection to register property automatically.