Your problem occurs when assigning a value of type Nullable<DateTime> with DateTime , currently, you declare the dates in the following way:
public DateTime FechaAsign { get; set; }
public DateTime FechaCierre { get; set; }
DateTime is a structure that can not be assigned null , I think the same thing happens with any structure.
So you must declare the variable as a value capable of receiving null by value and you can do it in the following way 1 :
Nullable<DateTime> FechaAssign { get; set; }
Nullable<DateTime> FechaCierre { get; set; }
Or the "pretty" :
DateTime? FechaAssign { get; set; }
DateTime? FechaCierre { get; set; }
This happens because in the declaration of the table in your database, the table accepts null by value in these fields.
If you want the fields to be the same as the previous ones, you should try to add the clause NOT NULL in the definition of the table in your database.
You must bear in mind that having a type Nullable<T> in your class, you do not directly access the member DateTime internal, but you must use the property .Value of the object.
To access the actual value of DateTime that you define in the query, you must do something like the following:
DateTime AlgunSitioDondeUsar = FechaAssign.Value; // Accede al DateTime interno.
Not to mention that you need to do a check of null to check the current value of the field.
Another Alternative:
Instead of altering the definition of your class Ticket , you can simply do a check in the query and it should work perfectly, with the exception that you will not have values null in the class, you can use a value as 01/01/1865 00:00:00 AM to represent a false value or null .
The query would look like the following:
query = (from q in _conexion.Ticket_Cab
where [bla..bla..bla]
select new Ticket { [bla..bla] FechaCreacion = q.tik_fechacreacion,
FechaModif = q.tik_fechamodif,
FechaAsign = q.tik_fechaAsign ?? DateTime.Parse("01/01/1800"),
FechaCierre = q.tik_fechaCierre ?? DateTime.Parse("01/01/1800") }
).ToList();
Where 01/01/1800 is the date that indicates that your value is false or null .
1 : You must do using System; when using this method.