Answer the question
In order to leave comments, you need to log in
How to return result with empty value?
There is a function that accepts a value that will be checked against the value from the entity.
public async Task<long?> GetId(long bookingId)
{
var bookPriceDb = await context.BookPrice.SingleOrDefaultAsync(x => x.BookingId == bookingId);
var Id = bookingId;
return Id;
}
if(bookPriceDb == null)
{
???
}
Answer the question
In order to leave comments, you need to log in
What to guess, you can clearly return found / not found
public async Task<(bool, long)> GetId(long bookingId)
How does your architecture imply error handling?
Throw an exception. Return Nan/Infinity/-1. Return not long, but something that can be nullable (although it seems like from some kind of sisharp this can be stirred up with simple types)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question