-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated QueryBuilder for Select operations * Added GetFirstWithSelectAsync()
- Loading branch information
1 parent
7c77a94
commit d067635
Showing
9 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using CSESoftware.Core.Entity; | ||
|
||
namespace CSESoftware.Repository.Builder | ||
{ | ||
public class QueryWithSelect<TEntity, TOut> : Query<TEntity>, IQueryWithSelect<TEntity, TOut> where TEntity : class, IEntity | ||
{ | ||
public QueryWithSelect(IQuery<TEntity> query) | ||
{ | ||
Predicate = query.Predicate; | ||
OrderBy = query.OrderBy; | ||
Include = query.Include; | ||
Skip = query.Skip; | ||
Take = query.Take; | ||
CancellationToken = query.CancellationToken; | ||
} | ||
|
||
public Expression<Func<TEntity, TOut>> Select { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using CSESoftware.Core.Entity; | ||
|
||
namespace CSESoftware.Repository.Builder | ||
{ | ||
public class SelectQueryBuilder<TEntity, TOut> where TEntity : class, IEntity | ||
{ | ||
internal readonly IQueryWithSelect<TEntity, TOut> _entity; | ||
|
||
public SelectQueryBuilder(IQuery<TEntity> entity) | ||
{ | ||
_entity = new QueryWithSelect<TEntity, TOut>(entity); | ||
} | ||
|
||
public SelectQueryBuilder(IQuery<TEntity> entity, Expression<Func<TEntity, TOut>> select) | ||
{ | ||
_entity = new QueryWithSelect<TEntity, TOut>(entity) | ||
{ | ||
Select = select | ||
}; | ||
} | ||
|
||
public IQueryWithSelect<TEntity, TOut> Build() | ||
{ | ||
return _entity; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using CSESoftware.Core.Entity; | ||
|
||
namespace CSESoftware.Repository | ||
{ | ||
public interface IQueryWithSelect<TEntity, TOut> : IQuery<TEntity> where TEntity : class, IEntity | ||
{ | ||
Expression<Func<TEntity, TOut>> Select { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters