I'm having trouble getting ExecuteStoreQuery to work correctly with my custom class which has a DateTime member. It gets 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();
MyInfo class definition:
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();
Although i am confused with your question, but instead of confusion i am trying to help based on best of my understanding. ;-)
Quick and easy way:
If you have trouble returning date time only, then you can use
If you want to return list of your custom class then, it will be simply
If only one class is required, I hope SIngleOrDefault() will work.
If you need only single value then