Hi
In below code i am getting error - Cannot convert system.date.time? to system.date.time
List
Thanks
Hi
In below code i am getting error - Cannot convert system.date.time? to system.date.time
List
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit MohantyPosted Apr 7, 2023, 1:49 PM
Tuhin PaulPosted Apr 7, 2023, 6:23 PM
Since the type of the objResult variable is already clear from the method name (GetSessionDeliveryParticipantList), you can use the var keyword to simplify the code
Tuhin PaulPosted Apr 7, 2023, 6:22 PM
Instead of using the ternary operator to check for null values and set a default value, you can use the null-coalescing operator (??) to provide a default value if the StartDate or EndDate properties are null
Jignesh KumarPosted Apr 7, 2023, 1:55 PM
Hi,
You are getting null value from database query response for datefield which is not nullable so it will throw error.
You can solve this problem in multiple ways,
You can add ? In your model as below
Public Datetime? StartDate {get; set;}