subsonic / SubSonic-3.0-Templates

T4 Template Project for the peeps
http://subsonic.github.io/
105 stars 46 forks source link

cannot retrieve record with LINQ #41

Open jmonfu opened 14 years ago

jmonfu commented 14 years ago

Hi

I have a table with 2 date fields, created as the new (date) datatype in SQL Server 2008. I am managing to insert a record, however, when I try to retreive it with LINQ, I am getting an error:-

"Object of type 'System.DateTime' cannot be converted to type 'System.String'."

My LINQ is as follows:-

Resume resume = (from p in db.Resumes where p.ResumeID == resumeID select p).ToList().FirstOrDefault();

and the SQL that is being produced is

SELECT [t0].[CompanyAddress], [t0].[CompanyTitle], [t0].[CompanyWebsite], [t0].[DateFrom], [t0].[DateTo], [t0].[Description], [t0].[JobTitle], [t0].[ResumeID] FROM [dbo].[Resume] AS t0 WHERE ([t0].[ResumeID] = 5)

If I change the datatype from date to datetime, everything works fine

Is there a problem with Subsonic on the new datatype (date) ?

Thanks