Skip to content

Commit cd0d8e1

Browse files
committed
Some fixes for interface
1 parent 72b2d6f commit cd0d8e1

12 files changed

Lines changed: 53 additions & 16 deletions

File tree

‎ManagedCode.Database.AzureTable/AzureTableDBCollectionQueryable.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ public override IAsyncEnumerable<TItem> ToAsyncEnumerable(CancellationToken canc
2222
SkipValue, cancellationToken);
2323
}
2424

25-
public override async Task<long> LongCountAsync(CancellationToken cancellationToken = default)
25+
public override Task<TItem> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
26+
{
27+
throw new System.NotImplementedException();
28+
}
29+
30+
public override async Task<long> CountAsync(CancellationToken cancellationToken = default)
2631
{
2732
long count = 0;
2833

‎ManagedCode.Database.Core/BaseDBCollectionQueryable.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public IDBCollectionQueryable<TSource> OrderByDescending(Expression<Func<TSource
4949
return this;
5050
}
5151

52-
public IDBCollectionQueryable<TSource> Take(int count)
52+
public IDBCollectionQueryable<TSource> Take(int? count)
5353
{
5454
TakeValue = count;
5555
return this;
@@ -62,8 +62,9 @@ public IDBCollectionQueryable<TSource> Skip(int count)
6262
}
6363

6464
public abstract IAsyncEnumerable<TSource> ToAsyncEnumerable(CancellationToken cancellationToken = default);
65+
public abstract Task<TSource> FirstOrDefaultAsync(CancellationToken cancellationToken = default);
6566

66-
public abstract Task<long> LongCountAsync(CancellationToken cancellationToken = default);
67+
public abstract Task<long> CountAsync(CancellationToken cancellationToken = default);
6768

6869
public abstract Task<int> DeleteAsync(CancellationToken cancellationToken = default);
6970

‎ManagedCode.Database.Core/IDBCollection.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace ManagedCode.Database.Core;
77

88
public interface IDBCollection<in TId, TItem> : IDisposable, IAsyncDisposable where TItem : IItem<TId>
99
{
10+
IDBCollectionQueryable<TItem> Query { get; }
11+
1012
Task<TItem> InsertAsync(TItem item, CancellationToken token = default);
1113
Task<int> InsertAsync(IEnumerable<TItem> items, CancellationToken token = default);
1214

@@ -24,8 +26,6 @@ public interface IDBCollection<in TId, TItem> : IDisposable, IAsyncDisposable wh
2426
Task<bool> DeleteAllAsync(CancellationToken token = default);
2527

2628
Task<TItem> GetAsync(TId id, CancellationToken token = default);
27-
29+
2830
Task<long> CountAsync(CancellationToken token = default);
29-
30-
IDBCollectionQueryable<TItem> Query { get; }
3131
}

‎ManagedCode.Database.Core/IDBCollectionQueryable.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public interface IDBCollectionQueryable<TSource> : IDBCollectionQueryableResultA
1010
IDBCollectionQueryable<TSource> OrderBy(Expression<Func<TSource, object>> keySelectorF, Expression<Func<TSource, object>> keySelectorS);
1111
IDBCollectionQueryable<TSource> OrderByDescending(Expression<Func<TSource, object>> keySelector);
1212
IDBCollectionQueryable<TSource> OrderByDescending(Expression<Func<TSource, object>> keySelectorF, Expression<Func<TSource, object>> keySelectorS);
13-
IDBCollectionQueryable<TSource> Take(int count);
13+
IDBCollectionQueryable<TSource> Take(int? count);
1414
IDBCollectionQueryable<TSource> Skip(int count);
1515
}

‎ManagedCode.Database.Core/IDBCollectionQueryableResultAsync.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ namespace ManagedCode.Database.Core;
66

77
public interface IDBCollectionQueryableResultAsync<T>
88
{
9-
Task<List<T>> ToListAsync(CancellationToken cancellationToken = default);
109
IAsyncEnumerable<T> ToAsyncEnumerable(CancellationToken cancellationToken = default);
11-
Task<long> LongCountAsync(CancellationToken cancellationToken = default);
10+
Task<T> FirstOrDefaultAsync(CancellationToken cancellationToken = default);
11+
Task<List<T>> ToListAsync(CancellationToken cancellationToken = default);
12+
Task<long> CountAsync(CancellationToken cancellationToken = default);
1213
Task<int> DeleteAsync(CancellationToken cancellationToken = default);
1314
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ public override async IAsyncEnumerable<TItem> ToAsyncEnumerable(CancellationToke
9696
}
9797
}
9898

99-
public override Task<long> LongCountAsync(CancellationToken cancellationToken = default)
99+
public override Task<TItem> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
100+
{
101+
throw new System.NotImplementedException();
102+
}
103+
104+
public override Task<long> CountAsync(CancellationToken cancellationToken = default)
100105
{
101106
return Task.FromResult((long)GetItemsInternal().Count());
102107
}

‎ManagedCode.Database.CosmosDB/CosmosDBCollectionQueryable.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ public override async IAsyncEnumerable<TItem> ToAsyncEnumerable(CancellationToke
8989
}
9090
}
9191

92-
public override async Task<long> LongCountAsync(CancellationToken cancellationToken = default)
92+
public override Task<TItem> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
93+
{
94+
throw new NotImplementedException();
95+
}
96+
97+
public override async Task<long> CountAsync(CancellationToken cancellationToken = default)
9398
{
9499
foreach (var predicate in WherePredicates)
95100
{

‎ManagedCode.Database.LiteDB/LiteDbDBCollectionQueryable.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ public override async IAsyncEnumerable<TItem> ToAsyncEnumerable(CancellationToke
6060
}
6161
}
6262

63-
public override async Task<long> LongCountAsync(CancellationToken cancellationToken = default)
63+
public override Task<TItem> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
64+
{
65+
throw new System.NotImplementedException();
66+
}
67+
68+
public override async Task<long> CountAsync(CancellationToken cancellationToken = default)
6469
{
6570
await Task.Yield();
6671
var query = _collection.Query();

‎ManagedCode.Database.MongoDB/MongoDbDBCollectionQueryable.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public override async IAsyncEnumerable<TItem> ToAsyncEnumerable(CancellationToke
6161
}
6262
}
6363

64-
public override async Task<long> LongCountAsync(CancellationToken cancellationToken = default)
64+
public override Task<TItem> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
65+
{
66+
throw new NotImplementedException();
67+
}
68+
69+
public override async Task<long> CountAsync(CancellationToken cancellationToken = default)
6570
{
6671
var query = _collection.AsQueryable();
6772
foreach (var predicate in WherePredicates)

‎ManagedCode.Database.SQLite/SQLiteDBCollectionQueryable.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ public override async IAsyncEnumerable<TItem> ToAsyncEnumerable(CancellationToke
6060
}
6161
}
6262

63-
public override async Task<long> LongCountAsync(CancellationToken cancellationToken = default)
63+
public override Task<TItem> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
64+
{
65+
throw new System.NotImplementedException();
66+
}
67+
68+
public override async Task<long> CountAsync(CancellationToken cancellationToken = default)
6469
{
6570
await Task.Yield();
6671

0 commit comments

Comments
 (0)