Hello everyone,
After implement this code,
- public class MainUserLogin
- {
- public Nullable<DateTime> LogInTime { get; set; }
- public Nullable<DateTime> LogOutTime { get; set; }
- public Int64 Id { get; set; }
- public string FirstName { get; set; }
- public string SurName { get; set; }
- }
- List< MainUserLogin> objUserSetUp = userList.Select(m => new MainUserLogin()
- {
- Id = m.Field<Int64>("Id"),
- FirstName = m.Field<string>("FirstName"),
- SurName = m.Field<string>("SurName"),
- LogInTime = m.Field<DateTime?>("LogInTime"),
- LogOutTime = m.Field<DateTime?>("LogOutTime")
- }).ToList();
If LoginTime or LogOutTime is existing null then the error is happening "Specified cast is not valid."
How can I solve this error?