Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Nullable foreign key causes runtime error in OData service

Nullable foreign key causes runtime error in OData service

Scheduled Pinned Locked Moved C#
helpasp-netcsharpdatabasedotnet
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Wright 2022
    wrote on last edited by
    #1

    I have used OData in my asp.net core project. I have problem with nullable foreign keys. When I want to use expand in url query, there is an exception that says:

    System.InvalidOperationException: Nullable object must have a value.

    I have provided a simple reproducible project in GitHub GitHub - codeblock88/temp: This repository is used for debugging.[^]repository. Please help me to solve this problem.

    L Richard DeemingR M 4 Replies Last reply
    0
    • A Alex Wright 2022

      I have used OData in my asp.net core project. I have problem with nullable foreign keys. When I want to use expand in url query, there is an exception that says:

      System.InvalidOperationException: Nullable object must have a value.

      I have provided a simple reproducible project in GitHub GitHub - codeblock88/temp: This repository is used for debugging.[^]repository. Please help me to solve this problem.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If a key is nullable then how can it be used to maintain referential integrity?

      A 1 Reply Last reply
      0
      • L Lost User

        If a key is nullable then how can it be used to maintain referential integrity?

        A Offline
        A Offline
        Alex Wright 2022
        wrote on last edited by
        #3

        I want to expand it for records are not null.

        D L 2 Replies Last reply
        0
        • A Alex Wright 2022

          I want to expand it for records are not null.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          It's not "records" that can be null, but individual fields in the record. You're not making much sense, so you're going to have to do a much better job of explaining what you're trying to do. As for the error you're getting, show the code that's throwing it.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          1 Reply Last reply
          0
          • A Alex Wright 2022

            I have used OData in my asp.net core project. I have problem with nullable foreign keys. When I want to use expand in url query, there is an exception that says:

            System.InvalidOperationException: Nullable object must have a value.

            I have provided a simple reproducible project in GitHub GitHub - codeblock88/temp: This repository is used for debugging.[^]repository. Please help me to solve this problem.

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            There's nothing in that project that would actually call your API and produce that error. Where's the actual reproduction of the error?


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            1 Reply Last reply
            0
            • A Alex Wright 2022

              I want to expand it for records are not null.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I have no idea what you mean by that, or what it has to do with your original question.

              1 Reply Last reply
              0
              • A Alex Wright 2022

                I have used OData in my asp.net core project. I have problem with nullable foreign keys. When I want to use expand in url query, there is an exception that says:

                System.InvalidOperationException: Nullable object must have a value.

                I have provided a simple reproducible project in GitHub GitHub - codeblock88/temp: This repository is used for debugging.[^]repository. Please help me to solve this problem.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                "Nullable foreign keys". Sounds like the definition of an orphan. (You need a "null' parent in those cases; if you want to stay sane)

                "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                1 Reply Last reply
                0
                • A Alex Wright 2022

                  I have used OData in my asp.net core project. I have problem with nullable foreign keys. When I want to use expand in url query, there is an exception that says:

                  System.InvalidOperationException: Nullable object must have a value.

                  I have provided a simple reproducible project in GitHub GitHub - codeblock88/temp: This repository is used for debugging.[^]repository. Please help me to solve this problem.

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #8

                  Replace the null with a zero and filter them out in your query.

                  Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups