File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
DDDToolkit.Repository.Sql
DDDToolkit.Utilities/Extensions Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
# DDDToolkit
2
- preview: ![ preview build status ] ( https://ninthlight.visualstudio.com/_apis/public/build/definitions/2a0b2dd5-5fb3-41e4-a3bb-09ae80277b94/6/badge )
2
+ [ < img src = " https://ninthlight.visualstudio.com/_apis/public/build/definitions/2a0b2dd5-5fb3-41e4-a3bb-09ae80277b94/6/badge " /> ] ( https://ninthlight.visualstudio.com/2a0b2dd5-5fb3-41e4-a3bb-09ae80277b94/_build/index?definitionId=6 )
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public ReadableRepository(TContext dbContext) : base(dbContext) { }
23
23
protected virtual IQueryable < T > ApplyIncludes ( IQueryable < T > query ) => query . IncludeEverything ( ) ;
24
24
protected virtual IQueryable < T > Queryable => ApplyIncludes ( Set . AsNoTracking ( ) ) ;
25
25
26
- public Task < IReadOnlyCollection < T > > GetAll ( ) => Set . ToListAsync ( ) . ConvertTask ( ) . To < IReadOnlyCollection < T > > ( ) ;
26
+ public Task < IReadOnlyCollection < T > > GetAll ( ) => Set . ToListAsync ( ) . ToReadOnlyCollection ( ) ;
27
27
28
28
public Task < T > GetById ( TId id )
29
29
{
@@ -38,7 +38,7 @@ public Task<T> GetById(TId id)
38
38
39
39
public Task < IReadOnlyCollection < T > > Query ( Expression < Func < T , bool > > query )
40
40
{
41
- return Set . Where ( query ) . ToListAsync ( ) . ConvertTask ( ) . To < IReadOnlyCollection < T > > ( ) ;
41
+ return Set . Where ( query ) . ToListAsync ( ) . ToReadOnlyCollection ( ) ;
42
42
}
43
43
}
44
44
}
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ namespace DDDToolkit.Utilities.Extensions
6
6
{
7
7
public static class TaskExtensions
8
8
{
9
+ public static Task < IReadOnlyCollection < T > > ToReadOnlyCollection < T > ( this Task < List < T > > task )
10
+ => task . ContinueWith ( t => t . Result . AsReadOnly ( ) ) . ConvertTask ( ) . ToTaskOf < IReadOnlyCollection < T > > ( ) ;
11
+
9
12
public static TaskConverter < T > ConvertTask < T > ( this Task < T > task )
10
13
{
11
14
return new TaskConverter < T > ( task ) ;
@@ -20,7 +23,7 @@ public TaskConverter(Task<T> task)
20
23
_task = task ;
21
24
}
22
25
23
- public Task < TResult > To < TResult > ( )
26
+ public Task < TResult > ToTaskOf < TResult > ( )
24
27
where TResult : class
25
28
{
26
29
if ( ! typeof ( TResult ) . IsAssignableFrom ( typeof ( T ) ) )
@@ -29,6 +32,10 @@ public Task<TResult> To<TResult>()
29
32
}
30
33
return _task . ContinueWith ( t => t . Result as TResult ) ;
31
34
}
35
+
36
+ public Task < TResult > To < TResult > ( )
37
+ where TResult : class
38
+ => ToTaskOf < TResult > ( ) ;
32
39
}
33
40
34
41
}
You can’t perform that action at this time.
0 commit comments