New Posts New Posts RSS Feed: using Take() in EntityServerQueryInterceptor
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

using Take() in EntityServerQueryInterceptor

 Post Reply Post Reply
Author
ajhops View Drop Down
Newbie
Newbie
Avatar

Joined: 23-Aug-2010
Posts: 11
Post Options Post Options   Quote ajhops Quote  Post ReplyReply Direct Link To This Post Topic: using Take() in EntityServerQueryInterceptor
    Posted: 10-May-2012 at 11:08am
I have an EntityServerQueryInterceptor. 
I want to ensure that for a given entity type, any query is sorted by date and only the latest N elements are returned.
I understand how to add a filter, but I don't understand how to use Take() in the FilterQuery override.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 10-May-2012 at 2:42pm
Hi ajhops,
 
In this case, you'd need to alter the query in the interceptor:
 
protected override bool FilterQuery() {
  if (this.Query.QueryableType == typeof(Order)) {
    this.Query = ((EntityQuery<Order>)this.Query).OrderBy(o => o.OrderDate).Take(10);
  }
  return base.FilterQuery();
}
 
Regards,
   Silvio.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down