On 2015-08-22 10:57 PM, Steffen Mangold wrote:
>> how can I trunc time in EntityFramework?
>>
>> I tried it this way:
>>
>>      model.Datas
>>                             .GroupBy(d => 
>> DbFunctions.TruncateTime(d.TimeStamp))
>>                             .Select(d => d.Key.Value)
>>                             .ToArray();
>>
>> But get this error:
>>      "SQLite error (1): no such function: TruncateTime"
>>
>> How else can I use the "date(timestring) function in EntityFramework?
>>
> No solution for this? :(
>
> Regards Steffen

Hi Steffen,
The little sadface prompted me to respond... :)

it's not that we don't want to answer, but that question is about a 
framework, not about SQLite, and very few people here might know how to 
do what you want, and those who do might not read it every day.

I do not know what ".GroupBy(d => DbFunction.TruncateTime(d.TimeStamp))" 
does at all...

I mean we've been around long enough to deduce the gist of what you are 
doing via some model-view system, but can't speak with any authority 
about it.
What I can tell for sure, is that those are not SQLite functions, nor 
are they SQL. Whatever you use to translate that code into something 
that spits out data is not a thing any of us have any authority on 
(well, some might).

It's a bit like buying a surfboard and tying it to the roof of your car 
and then asking the surf-board manufacturer if he can tell you how fast 
you can go like that... (He might suggest not to go too fast as a 
standard precaution, but can't speak definitively or with any authority 
on the subject).

I can tell you how to do what you want in SQL and in SQLite, though I am 
sure it won't help your case.

But, on the off chance it does, here goes:
The SQL to achieve what you want (as understood by SQLite) /might/ be 
like this:

SELECT date(d.TimeStamp) FROM sometable AS d WHERE d.Key='somevalue' 
GROUP BY date(d.TimeStamp);


And if you feed that into the C function in SQLite interface called 
sqlite3_prepareV2() as defined in the DLL you are linking against (I 
assume) then it will start a cursor and return a pointer to a prepared 
statement you can use to retrieve successive rows.

You might even be able to peek into your model and influence or change 
the actual SQL that reaches the engine directly, which might help, 
though the idea with those frameworks is probably to stay removed from 
the nuts and bolts.

Ok, that's a really convoluted way of saying, sorry, I am stupid, have 
no idea what you are talking about. I assume some Entity framework 
groupies might be able to help more or maybe someone here with knowledge 
of that framework might spot the request in the coming week and assist, 
but don't hold your breath.

Best of luck,
Ryan

Reply via email to