When using Entity Framework, I’ve found that the join LINQ query that I specified will not return all the data I needed.
Although the query includes OpmaDB.Property entity, the entity is not included in the result object. So, statement like:
will return the famous-‘Object reference not set to an object of an instance’-error:
To resolve this issue, we can use ViewModel, or Model Binder, instead of the entity itself. This should be the better practice anyway. The query looks like:
And the ViewModel looks like this:
Alternatively, we can also store the whole entity model in the View Model instead of property members of the entity. This is how I would do it, the ViewModel:
And the query: