我正在从SQL数据库中读取datetime字段,定义为datetime,null。
这是我的读物:
var _dataContextOrders = new OrderClassesDataContext();
var ordersData = (from o in _dataContextOrders.Orders
join s in _dataContextOrders.FMSSuppliers on o.SupplierID equals s.ID
join os in _dataContextOrders.StatusCodes on o.OrderStatusCode equals os.StatusCode1
join pc in _dataContextOrders.Persons on o.CreatorPersonID equals pc.ID
select new OrderData
{
ID=o.ID,
ApprovedDate= o.ApprovedDate
}).SingleOrDefault(o => o.ID == _intOrderId);
return ordersData;
字段ApprovedDate即使在有值的情况下也会返回null。 OrderData记录在此处定义:
public class OrderData
{
public int ID { get; set; }
public DateTime? ApprovedDate { get; set; }
}
我知道该字段有一个值,因为我在SQL中检查过。如何让它返回一个值?