Fix null reference issue in ReadAsync method

Updated the inclusion of the `States` property in the
`ReadAsync` method of `ProfileObjRepository` to check
for null values before accessing `State1`. This change
prevents potential null reference exceptions.
This commit is contained in:
2025-08-01 10:07:30 +02:00
parent b89a69b0f3
commit 2fd64cb616

View File

@@ -35,6 +35,6 @@ public class ProfileObjRepository : IProfileObjRepository
public async Task<IEnumerable<ProfileObject>> ReadAsync(int userId, int profileId, CancellationToken cancel = default)
=> await _context.Objects
.FromSqlRaw("SELECT * FROM [FNMWF_GET_PROFILE_OBJECTS] ({0}, {1})", userId, profileId)
.Include(obj => obj.States).ThenInclude(objState => objState.State1)
.Include(obj => obj.States).ThenInclude(objState => objState != null ? objState.State1 : null)
.ToListAsync(cancel);
}