Hello everyone,
After implement this code,
- public class MainUserLogin
- {
- public Nullable
LogInTime { get; set; } - public Nullable
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
("Id"), - FirstName = m.Field<string>("FirstName"),
- SurName = m.Field<string>("SurName"),
- LogInTime = m.Field
("LogInTime"), - LogOutTime = m.Field
("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?


Manas MohapatraRank #182 · 13.2K reputationPosted Dec 7, 2016, 1:43 AM EST
Prakash KumarRank #1,799 · 828 reputationPosted Dec 7, 2016, 2:14 AM EST
Abhilash J ARank #1,243 · 1.4K reputationPosted Dec 7, 2016, 2:12 AM EST