Skip to content

Commit 96c481f

Browse files
author
Alexander
committed
1 parent e658cb9 commit 96c481f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/AbpODataDemo.WebApi/Controllers/AbpODataEntityController.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)