Monday, 9 September 2013

ExecuteStoreQuery not working with DateTime setter

ExecuteStoreQuery not working with DateTime setter

I'm having trouble getting ExecuteStoreQuery to work correctly with a
DateTime setter. It sets the sets the default DateTime value (1/1/0001
12:00:00 AM) instead of what is in the database.
List<MyInfo> results = context.ExecuteStoreQuery<MyInfo>(SELECT
[StartTime] FROM [dbo].[Records] WHERE [Type] = 1).ToList();
public class MyInfo
{
private DateTime startTime;
public DateTime StartTime
{
get { return startTime; }
set { startTime = value; }
}
}
However if I query using DateTime instead of MyInfo, the correct date is
returned.
List<DateTime> results = context.ExecuteStoreQuery<DateTime>(SELECT
[StartTime] FROM [dbo].[Records] WHERE [Type] = 1).ToList();
I want to return more than just that one column, so I'd really like to get
MyInfo working. It works for Strings, but not for DateTime.

No comments:

Post a Comment