Activities of "ademaygun"

  • ABP Framework version: v3.3.1
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): no I am using postgres database and I want the if values are set with empty strings, they should automatically become null. So, I overrode SaveChanges() methods in MyStoreDbContext (in EntityFrameworkCore project) and add an method that called RemoveEmptyStrings() from* stackoverflow and my problem fixed. But is this best solution or does ABP provide any solution to this empty string problem?
public void RemoveEmptyStrings()
{
    // Look for changes
    this.ChangeTracker.DetectChanges();

    // Loop through each entity
    foreach (var entity in this.ChangeTracker.Entries())
    {
        // Use reflection to find editable string properties
        var properties = from p in entity.Entity.GetType().GetProperties()
            where p.PropertyType == typeof(string)
                  && p.CanRead
                  && p.CanWrite
            select p;

        // Loop through each property and replace empty strings with null
        foreach (var property in properties)
        {
            if (string.IsNullOrWhiteSpace(property.GetValue(entity.Entity, null) as string))
                property.SetValue(entity.Entity, null, null);
       }
    }
}
  • Exception message and stack trace:
  • Steps to reproduce the issue:
Showing 81 to 81 of 81 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11