none
Why would .Include() throw a null reference exception? RRS feed

  • Question

  • Executing a simple query through [dbContext].[table/object].FromSql("select ....")

    When I append an ".Includes(...)" method the execution returns a null reference exception, even though it has worked in the past and there is corresponding data to "include" for every table row + navigation.

    Why would .include() throw such an exception? If there is no related data shouldn't the navigation object just be empty / null?

    Likewise, if I were to test for null, what syntax would be used in relation to .include()?

    Thanks!


    Karl


    • Edited by Karl K Sunday, November 6, 2016 5:08 AM
    Sunday, November 6, 2016 5:07 AM

Answers

  • A column in the table targeted by "include" was marked not null when it should have allowed nulls. It would be helpful if error messages identified the elements which trigger them.

    • Marked as answer by Karl K Sunday, November 6, 2016 8:02 PM
    • Edited by Karl K Sunday, November 6, 2016 8:03 PM
    Sunday, November 6, 2016 8:02 PM