The object i is from database. PrDT is a string, PrDateTime is DataTimeOffset type, nullable
vi.PrDT = i.PrDateTime.Value.ToString("s");
What is the quick way? I don't want if else etc...
Using the conditional operator:
vi.PrDT = i.PrDateTime.HasValue ? i.PrDateTime.Value.ToString("s") :
string.Empty;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With