Entity 4.0 Casting Value As DateTime

后端 未结 4 1539
南笙
南笙 2021-01-25 14:32

LINQ to Entity Framework 4.0. SQL Server.

I\'m trying to return a list of objects and one of the columns in the database is varchar(255) and contains dates. I\'m tryin

相关标签:
4条回答
  • 2021-01-25 14:44

    You want DateTime.Parse(c.value) which will take a string containing a date and create a DateTime object out of it.

    0 讨论(0)
  • 2021-01-25 14:50

    The answer is it's not currently possible with Entity Framework. With LINQ itself it is, just not supported with Entity Framework.

    0 讨论(0)
  • 2021-01-25 14:55

    read, And the best bet would be using your result and then Converting to date time. Like below,

     static void Main(string[] args)
         {
            Console.WriteLine(getme());
            Console.ReadLine(); 
        }
        private static DateTime  getme()
        {
            List<string> ss = new List<string>();
            ss.Add("11/11/2010");
            var r = from l in ss
                    select new { date = Convert.ToDateTime(l) };
    
    
    
            return r.FirstOrDefault().date;
    
        }
    
    0 讨论(0)
  • 2021-01-25 15:04

    you can do like this Date=DateTime.Parse(text)

    0 讨论(0)
提交回复
热议问题