Home Issue with occasionally null property
Reply: 0

Issue with occasionally null property

user1167 Published in July 20, 2018, 4:57 am

This is an asp.net MVC project using LINQ and c#.

I'm pulling a list of records(list1) from an API. I then have a table(table1) associated to some of these records(list1) if I have created one. This table(table1) is for rating the records coming from the service(list1).

I can't use a calculated field on list1 because for performance reasons; I'd like to be able to store the value in table1 and just look at the most up to date rating.

Everything seems to work fine except that I can't use this field on a view because I get an object reference does not equal... It can't handle the null value that exists sometimes.

My view looks like:

Html.DisplayFor(modelItem => list1.table1.Rating)%

My attempted model looks like:

public Table1 Table1 { get; set; }

Table1 is linked to list1 by an id.

So first - is there any way to save what I've done and just tell the view to return blank if there's no record in table1 that links to list1.

If not, how else can I store this record and have it associated with list1?

Thank you

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320612 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO