From edf7b1a7efddf0d5388f06308fc2409af35637b4 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 4 Nov 2022 15:00:03 -0400 Subject: [PATCH] try parse Size as a long (#2383) --- .../BaseEntityFrameworkRepository.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Infrastructure.EntityFramework/Repositories/BaseEntityFrameworkRepository.cs b/src/Infrastructure.EntityFramework/Repositories/BaseEntityFrameworkRepository.cs index 6d179f0159..c2dde1b04d 100644 --- a/src/Infrastructure.EntityFramework/Repositories/BaseEntityFrameworkRepository.cs +++ b/src/Infrastructure.EntityFramework/Repositories/BaseEntityFrameworkRepository.cs @@ -124,8 +124,14 @@ public abstract class BaseEntityFrameworkRepository !string.IsNullOrWhiteSpace(e.Attachments)) .Select(e => e.Attachments) .ToListAsync(); - var storage = attachments.Sum(e => JsonDocument.Parse(e)?.RootElement.EnumerateObject() - .Sum(p => p.Value.GetProperty("Size").GetInt64()) ?? 0); + var storage = attachments.Sum(e => JsonDocument.Parse(e)?.RootElement.EnumerateObject().Sum(p => + { + if (long.TryParse(p.Value.GetProperty("Size").ToString(), out var s)) + { + return s; + } + return 0; + }) ?? 0); var organization = new Organization { Id = organizationId, @@ -152,8 +158,14 @@ public abstract class BaseEntityFrameworkRepository !string.IsNullOrWhiteSpace(e.Attachments)) .Select(e => e.Attachments) .ToListAsync(); - var storage = attachments.Sum(e => JsonDocument.Parse(e)?.RootElement.EnumerateObject() - .Sum(p => p.Value.GetProperty("Size").GetInt64()) ?? 0); + var storage = attachments.Sum(e => JsonDocument.Parse(e)?.RootElement.EnumerateObject().Sum(p => + { + if (long.TryParse(p.Value.GetProperty("Size").ToString(), out var s)) + { + return s; + } + return 0; + }) ?? 0); var user = new Models.User { Id = userId,