I have the following LINQ expression. I want calculate the sum of numeric values in an nvarchar
field. I\'m using following code to do this, but I get an error
There is a badly built database, which I cannot edit, but have to use it.
I use this in Linq-To-Sql and it works.
First cast the string to object, then cast it to int.
from s in db.Students
select new
{
s.Name,
s.Surname,
Birthday = new DateTime((int)(object)(s.dateStr.Substring(0, 4)),
(int)(object)(s.dateStr.Substring(4, 2)),
(int)(object)(s.dateStr.Substring(6, 2))),
}