This question is locked. New answers and comments are not allowed.
Following converting to DateTime doesn't work. any body know the solution?
CL8 is string.
var q = DataContext.LOCATIONs.Where(Convert.ToDateTime(m.CL8) >= startDateTime );
6 Answers, 1 is accepted
0
Hi Libertad,
You can modify your query in the following way:
For now the best way to handle this specific type conversion is to use the SQL<T>() extensions method that allows you to write backend-dependent SQL code snippets and insert them in your LINQ queries.
Please note that the SQL statement in this case is specific to MS SQL Server and can fail if different backend is used.
Kind regards,
Viktor Zhivkov
the Telerik team
You can modify your query in the following way:
1.
var q = DataContext.LOCATIONs.Where(m=>
"convert(datetime, {0}) >= {1}"
.SQL<
bool
>(m.CL8, startDateTime));
For now the best way to handle this specific type conversion is to use the SQL<T>() extensions method that allows you to write backend-dependent SQL code snippets and insert them in your LINQ queries.
Please note that the SQL statement in this case is specific to MS SQL Server and can fail if different backend is used.
Kind regards,
Viktor Zhivkov
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Libertad
Top achievements
Rank 1
answered on 01 Feb 2013, 03:43 PM
Thanks Viktor,
but on backend I'm using Oracle. Is that work in this situation too?
but on backend I'm using Oracle. Is that work in this situation too?
0
Hello Libertad,
You can find more details about the TO_DATE function here.
I hope this information is helpful for you.
Do come back in case you need further assistance.
Greetings,
Ralph
the Telerik team
You can call the TO_DATE function in oracle to convert string values to datetime values. This would look like this:
var q = DataContext.LOCATIONs.Where(m =>
"to_date({0}, 'yyyy/mm/dd') >= {1}"
.SQL<
bool
>(m.CL8, startDateTime));
I hope this information is helpful for you.
Do come back in case you need further assistance.
Greetings,
Ralph
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
Stephen
Top achievements
Rank 1
answered on 13 Nov 2014, 11:04 PM
Ralph,
Could you please tell me the namespace in which to find the SQL extension method to which you refer? I've ransacked the Internet and can find no mention of such.
Regards,
Stephen
Could you please tell me the namespace in which to find the SQL extension method to which you refer? I've ransacked the Internet and can find no mention of such.
Regards,
Stephen
0
Hello Stephen,
The namespace is Telerik.OpenAccess.
Hope this helps.
Feel free to ask in case you have any other question.
Regards,
Ralph Waldenmaier
Telerik
The namespace is Telerik.OpenAccess.
using
Telerik.OpenAccess
Hope this helps.
Feel free to ask in case you have any other question.
Regards,
Ralph Waldenmaier
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
0
Bruno Carlos
Top achievements
Rank 1
answered on 08 May 2016, 04:32 PM
Please tell me where i can find this extension methods, String.SQL<T>, I need this ASAP.