I am trying to create a SQLITE query like this (first approach):
int count;
using ( var db = new SQLiteConnection( new SQLitePlatformWinRT(), DbPath ) )
{
count = ( from p in db.Table<TickRecord>()
where (p.TickStartDate.LocalDateTime >= start && p.TickEndtDate.LocalDateTime <= end )
select (int)p.DurationInSeconds ).Sum();
}
return count;
When running the query the application crash on the where clause.
I was able to achieve it like this (second approach):
ObservableCollection<TickRecord> records;
// Create a new connection
using ( var db = new SQLiteConnection( new SQLitePlatformWinRT(), DbPath ) )
{
records = new ObservableCollection<TickRecord>( db.Table<TickRecord>().Select( i => i ) );
}
int count = records.Where( record => record.TickStartDate.LocalDateTime >= start && record.TickEndDate.LocalDateTime <= end ).Sum( record => record.DurationInSeconds );
Is there a way to achieve the same using my first approach?
Thx
Aucun commentaire:
Enregistrer un commentaire