Created
March 9, 2013 04:35
-
-
Save phatty/5122544 to your computer and use it in GitHub Desktop.
Convert nullable DateTime? to new format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public DataTable GetDelivery() | |
{ | |
try | |
{ | |
db_ProductionSystemEntities Context = this.GetContext(); | |
//var Records = Context.T_DELIVERY | |
// .Include("T_CUST_INFO") | |
// .Include("T_SHIPPING_COMPANY"); | |
var Records = (from delivery in Context.T_DELIVERY | |
join cust in Context.T_CUST_INFO on delivery.Cust_Digit equals cust.Cust_Digit | |
join ship in Context.T_SHIPPING_COMPANY on delivery.ShippingNo equals ship.ShippingNo | |
orderby cust.Cust_Digit, delivery.DeliveryNo, delivery.Deli_DueDate ascending | |
select | |
new | |
{ | |
_Cust_Digit = delivery.Cust_Digit, | |
_Cust_Name = cust.Cust_Name, | |
_DeliveryNo = delivery.DeliveryNo, | |
_LotNumber = delivery.LotNumber, | |
_Deli_DueDate = delivery.Deli_DueDate, | |
_Deli_Description = delivery.Deli_Description, | |
_ShippingNo = delivery.ShippingNo, | |
_SpecialField1 = delivery.SpecialField1, | |
_SpecialField2 = delivery.SpecialField2 | |
}).AsEnumerable() | |
.Select(x => new { | |
Cust_Digit = x._Cust_Digit, | |
Cust_Name = x._Cust_Name, | |
DeliveryNo = x._DeliveryNo, | |
LotNumber = x._LotNumber, | |
Deli_DueDate = (x._Deli_DueDate ?? DateTime.MaxValue) == DateTime.MaxValue? "":(x._Deli_DueDate ?? DateTime.MaxValue).ToString("yyyy-mm-dd") , | |
Deli_Description = x._Deli_Description, | |
ShippingNo = x._ShippingNo, | |
SpecialField1 = x._SpecialField1, | |
SpecialField2 = x._SpecialField2, | |
}); | |
DataTable dt = EntityUtility.LINQToDataTable(Records); | |
return dt; | |
} | |
catch (Exception ex) | |
{ | |
throw ex; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment