How to save MySQL timestamp as String instead of DateTime using AutoMapper?

I use AutoMapper to store MySQL results in a list, this has information about when the last row was updated. Then, "timestamp" will be used to query the database for updates. But, I'm afraid that using a C # DateTime type will change the time zone, depending on the user's location. Since I ran into this problem earlier in the development cycle.

So basically, my question is, how can I make sure the โ€œtimestampโ€ saved with AutoMapper is not changed and can be used again to query the database?

Edit: This is the code used to convert the results.

public class Entry { public UInt32 id { get; set; } public string ... { get; set; } public UInt16 ... { get; set; } public string ... { get; set; } public string lastupdated { get; set; } // Using DateTime works, also tried value.ToString() public string ... { get; set; } public UInt16 ... { get; set; } } List<Entry> users = AutoMapper.Mapper.Map<MySqlDataReader,List<Entry>>(dbReader); 
+4
source share
1 answer

You can implement this with custom formatting.

For more information on how to implement such a formatter, see the CodeProject article: http://www.codeproject.com/KB/codegen/automapperformatters.aspx .

+1
source

All Articles