Change format of one column when mapping ? #1450
Unanswered
FredericCharliers
asked this question in
Q&A
Replies: 1 comment
-
public class DM
{
public DateTime FirstDate { get; set; }
public DateTime? SecondDate { get; set; }
}
public class DmMap: ClassMap<DM>
{
public DmMap()
{
Map(m => m.FirstDate).ConvertUsing(m => m.FirstDate.ToString("dd/MM/yyyy"));
Map(m => m.SecondDate).ConvertUsing(m => m.SecondDate?.ToString("MM/dd/yyyy") ?? string.Empty);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
Just a simple question : I have the following datamodel
public class DM()
{
public dateTime firstDate{get;set;}
public dateTime secondDate{get;set;}
}
I would like to provide a csv file that represent the firstDate as "dd/MM/yyyy" and the secondDate as "MM/dd/yyyy" .. how can I do that properly with csvHelper ?
is it possible to change anything in the ClassMap<> object ?? At this time I only see column mapping and column renaming.. could it possible to do something like this :
Map(m => m.LastHire.HasValue? m.LastHire.Value.ToString("dd/MM/yyyy"):string.Empty);
I suppose not but I can not see any clear sample on classMap (I found very light sample, but i need more)
regards.
F.
PS: Good job on the package, it's still a must!
Beta Was this translation helpful? Give feedback.
All reactions