.net - C# LINQ Query DateTime literal generated -
we using following code generate sql code query against firebird database;
dsrcash.getall(x => x.account.id == account.id && x.date_record <= dateto && x.date_record >= datefrom).tolist();
both dateto , datefrom parameters non nullable datetime , same respective database columns.
the sql clause generated follows;
where (struct_cas0_.deleted null) , struct_cas0_.account_id = 372 /* @p0 */ , struct_cas0_.date_record <= '2011-02-18t13:00:00.00' /* @p1 */ , struct_cas0_.date_record >= '2010-02-17t13:00:00.00' /* @p2 */
you can see datetime literal has been formatted using "s" or standard sortable format. appears firebird not support date format, if remove "t" datetime literal query execute successfully.
is possible change datetime conversion string being performed?
i should mention using nhibernate orm project.
i suppose use expression visitor when encountering date takes 2 paths. 1. if constant - replace string formatted correctly convert datetime 2. if memberexpression nothing.
this change sql
where (struct_cas0_.deleted null) , struct_cas0_.account_id = 372 /* @p0 */ , struct_cas0_.date_record <= cast('2011-02-18' datetime) /* @p1 */ , struct_cas0_.date_record >= cast('2010-02-18' datetime) /* @p2 */
Comments
Post a Comment