Question

Using the code below:

let student =
    query {
        for student in db.Student do
        where (student.StudentID = 1)
        select student
        exactlyOneOrDefault
    }

How do you check the value of student, and just what would be the default value if no match in the database was found?

Was it helpful?

Solution

Database objects come from the database library you're using (either LINQ-to-SQL or Entity Framework), they're not originated from F# so they're nullable. The value returned by exactlyOneOrDefault when there isn't exactly one is null.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top