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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user