public async Task<List<Note>>ShowAssigned()
{
return await _context.Notes
.Where(x => x.List.OwnerId != x.OwnerId)
.ToListAsync()
}
I get no syntax εrrors, but it seems you can't access attributes from related Data in this way.
Basically the goal is: A user creates a List, then some Notes for this List. Then he should be able to assign one of that Notes to another User. When that other User logs on, he should be able to see that new Note that was assigned to him.
Can anyone help me out with this?
public class List
{
public Guid ListId { get; set; }
public string OwnerId { get; set; }
public List<Note> Notes { get; set; }
}
public class Note
{
public Guid ID { get; set; }
public string OwnerId { get; set; }
[ForeignKey("ListId")]
public Guid ListId { get; set; }
public List List { get; set; }
}
And the context class:
public DbSet<Note> Notes { get; set; }
public DbSet<List> Lists { get; set; }
When i try to access Data the same way in a view like that:
@model List<Project.Models.Note>
@foreach (var item in Model)
{
if (item.List.OwnerId == item.OwnerId)
i get this error when running the web app (no syntax errors): NullReferenceException: Object reference not set to an instance of an object