Skip to content

Commit 8ed9b24

Browse files
author
Oleksii Sokol
committed
Fix SQLiteDBCollectionQueryable
1 parent 96b736f commit 8ed9b24

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

‎ManagedCode.Database.AzureTable/AzureTableDBCollectionQueryable.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ private static IAsyncEnumerable<TItem> ApplyPredicates(IAsyncEnumerable<TItem> a
6767
{
6868
case QueryType.OrderBy:
6969
asyncEnumerable = asyncEnumerable.OrderBy(x => query.ExpressionObject.Compile().Invoke(x));
70+
71+
// TODO: Maybe need to check is IOrderedEnumerable and do throw exception
7072
break;
7173
case QueryType.OrderByDescending:
7274
asyncEnumerable =
7375
asyncEnumerable.OrderByDescending(x => query.ExpressionObject.Compile().Invoke(x));
76+
77+
// TODO: Maybe need to check is IOrderedEnumerable and do throw exception
7478
break;
7579
case QueryType.ThenBy:
7680
{

‎ManagedCode.Database.Core/InMemory/InMemoryDBCollectionQueryable.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,17 @@ private IEnumerable<KeyValuePair<TId, TItem>> GetItemsInternal()
6666
throw new InvalidOperationException("Before ThenBy call first OrderBy.");
6767

6868
case QueryType.Take:
69-
items = items.Take(query.Count.GetValueOrDefault());
69+
if (query.Count.HasValue)
70+
{
71+
items = items.Take(query.Count.Value);
72+
}
7073
break;
7174

7275
case QueryType.Skip:
73-
items = items.Skip(query.Count.GetValueOrDefault());
76+
if(query.Count.HasValue)
77+
{
78+
items = items.Skip(query.Count.Value);
79+
}
7480
break;
7581

7682
default:

‎ManagedCode.Database.LiteDB/LiteDbDBCollectionQueryable.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ private IEnumerable<TItem> GetItemsInternal()
5959
throw new InvalidOperationException("LiteBD does not support ThenBy.");
6060

6161
case QueryType.Take:
62-
items = items.Take(query.Count.GetValueOrDefault());
62+
if (query.Count.HasValue)
63+
{
64+
items = items.Take(query.Count.Value);
65+
}
6366
break;
6467

6568
case QueryType.Skip:
66-
items = items.Skip(query.Count.GetValueOrDefault());
69+
if (query.Count.HasValue)
70+
{
71+
items = items.Skip(query.Count.Value);
72+
}
6773
break;
6874

6975
default:

‎ManagedCode.Database.SQLite/SQLiteDBCollectionQueryable.cs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public SQLiteDBCollectionQueryable(SQLiteConnection connection)
2020

2121
private IEnumerable<KeyValuePair<TId, TItem>> GetItemsInternal()
2222
{
23-
IEnumerable<KeyValuePair<TId, TItem>> items = _connection.Table<KeyValuePair<TId, TItem>>().AsEnumerable();
23+
IEnumerable<KeyValuePair<TId, TItem>> items = _connection.Table<KeyValuePair<TId, TItem>>();
2424

2525
foreach (var query in Predicates)
2626
{
@@ -64,11 +64,17 @@ private IEnumerable<KeyValuePair<TId, TItem>> GetItemsInternal()
6464
throw new InvalidOperationException("Before ThenBy call first OrderBy.");
6565

6666
case QueryType.Take:
67-
items = items.Take(query.Count.GetValueOrDefault());
67+
if (query.Count.HasValue)
68+
{
69+
items = items.Take(query.Count.Value);
70+
}
6871
break;
6972

7073
case QueryType.Skip:
71-
items = items.Skip(query.Count.GetValueOrDefault());
74+
if (query.Count.HasValue)
75+
{
76+
items = items.Skip(query.Count.Value);
77+
}
7278
break;
7379

7480
default:

0 commit comments

Comments
 (0)