@foreach (var a in Model.MESSAGES.OrderBy(p => p.DATE))
{
var id = a.SENDERID == ViewBag.KullaniciId ? a.SENTID : a.SENDERID;
var name = Model.USERS.FirstOrDefault(p => p.ID == id)?.NAMESURNAME;
<tr id="tr@(a.ID)">
<td>@name</td>
<td>@a.MESSAGE.Substring(0, Math.Min(100, a.MESSAGE.Length))</td>
</tr>
}
I get the following error :
System.NullReferenceException: Object reference not set to an instance of an object.
CoreFramework.Entities.Concrete.MEESAGES.Message.get returned null.