File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
src/AbpODataDemo.WebApi/Controllers Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ protected AbpODataEntityController(IRepository<TEntity> repository) : base(repos
2121 }
2222
2323 public abstract class AbpODataEntityController < TEntity , TPrimaryKey > : ODataController
24+ where TPrimaryKey : IEquatable < TPrimaryKey >
2425 where TEntity : class , IEntity < TPrimaryKey >
2526 {
2627 public IUnitOfWorkManager UnitOfWorkManager { get ; set ; }
@@ -50,10 +51,8 @@ public IQueryable<TEntity> Get()
5051 [ EnableQuery ]
5152 public SingleResult < TEntity > Get ( [ FromODataUri ] TPrimaryKey key )
5253 {
53- var entity = Repository . FirstOrDefault ( key ) ;
54-
55- //TODO: How to return a single value, instead of Queryable???
56- return SingleResult . Create ( new [ ] { entity } . AsQueryable ( ) ) ;
54+ var entity = Repository . GetAll ( ) . Where ( e => Equals ( e . Id , key ) ) ;
55+ return SingleResult . Create ( entity ) ;
5756 }
5857
5958 protected override void Dispose ( bool disposing )
@@ -69,4 +68,4 @@ protected override void Dispose(bool disposing)
6968 base . Dispose ( disposing ) ;
7069 }
7170 }
72- }
71+ }
You can’t perform that action at this time.
0 commit comments