Friday 15 March 2013

Custom date format in Linqpad -


I need LinqPad to render some date time columns with only date format, not part of time.

I tried to use data annotation attributes (such as in ASP.NET MVC) for my organizations:

  public class mortality {[datatype (datatype.det) }] [DisplayFormat (ApplyFormatInEditMode = true, DataFormatString = "{0: MM / dd / yyyy}")] Public Datime Activation Date {Receive; Set; }}   

But it seems that LinqPad does not recognize it.

How to implement custom formatting in LinqPad output?

Now, there are two options first to do this globally: edit | Preferences & gt; Enter the results, and the desired date time format string. The second is through a custom projection:

  New in the MyEntities {ActivationDate = m.ActivationDate.ToString (".... custom string ....."), .. Select.}   

This is an interesting question whether LINQPad should read and respect in providing DateTimes to DisplayTormatAttribute. I will look into it tomorrow and post it back.

No comments:

Post a Comment