WebAPI ODATA without EntityFramework
consider the following method in a WebApi controller:
[Queryable(AllowedQueryOptions= AllowedQueryOptions.All)]
public override IQueryable<Mandate> Get()
{
return new List<Mandate>() { new Mandate() {
Id = 1,
PolicyNumber = "350000000",
OpenPositions = new List<OpenPosition>(){
new OpenPosition(){ Id = 1, Amount =2300 },
new OpenPosition(){ Id = 2, Amount =2100 }
}},
new Mandate() {
Id = 2,
PolicyNumber = "240000000" ,
OpenPositions = new List<OpenPosition>(){
new OpenPosition(){ Id = 3, Amount =2500 },
new OpenPosition(){ Id = 2, Amount =2100 }
}
} }.AsQueryable<Mandate>();
}
Here the list is built manually and if I browse to the following url:
http://localhost:52446/odata/Mandates?$filter=Id eq 1 it returns the
correct item from the list.
Now obviously the list is more likely to be a database structure. Data
would be retrieved using some ORM and returned to the Web API service.
I don't use EntityFramework (and I can't because of legacy systems).
How would I use WebApi in this case ? How would I translate the url
parameters so that the filters are applied by the layer responsible of the
data access ?
No comments:
Post a Comment