Reputation: 21
In this foreach loop, I want to find my model with this Condition you see. The problem is I can't compare
b.GroupId
and group.GroupId
it says b.GroupId
is null but the group.GroupId
is not null I have traced it and it has a value of 1. This is my code
@foreach (var group in groups.Where(g => g.ParrentId == null))
{
<div class="tab-pane active animated fadeInRight" id="[email protected]">
var blog = Model.First(b=>b.GroupId==group.GroupId);
}
my model
@model IEnumerable<DataLayer.Entities.Blog.Blog>
@inject Core.Services.Interfaces.IGroupServices _groupServices;
@{
List<DataLayer.Entities.Group.Group> groups =
_groupServices.getAllGroups();}
as you see group.GroupId is 1 but 'a' is still 0 this is an example of my problem
Upvotes: 1
Views: 116
Reputation: 149
but the group.GroupId is not null
But as you stated the issues is with b, not with group. So somewhere in your model there is GroupId with null. It is unclear how to fix that since there are no information about your Model. But maybe something like this will help:
Model.First(b=>b.GroupId!=null && b.GroupId==group.GroupId);
Upvotes: 1