Using a converter with Linq

Dec 21, 2012 at 1:39 PM
Edited Dec 21, 2012 at 1:59 PM

I think I'm being dumb here, but I can't seem to get the syntax right.

I have to use a custom output format for a date to pass to a 3rd-party service.

I have a converter that works fine as a decoration on a property in a class if I was to do something like:

JsonConvert.SerializeObject(this); with a property defined:
[JsonConverter (typeof (jdateConverter) )] public DateTime since {get; set; }

But there are times the date is optional and should not be passed - so I now use a call to an external format routine, but I'd like to replace it and use the same converter instead. Now...

if (this.since > DateTime.MinValue)
  jo.Add( new JProperty ( "since", apiCommon.FormatApiDateParm( this.since )));

How would that statement be structured using a converter?

THanks, David