Skip to content

Instantly share code, notes, and snippets.

@dfch

dfch/00-README.md

Last active Feb 27, 2016
Embed
What would you like to do?
ODataQueryOptions do not apply $filter and $orderby options to IQueryable when using EntityFramework 6 with SQL Server
[AppclusiveAuthorize]
[EnableQuery(PageSize = 15)]
public async Task<IHttpActionResult> GetNodes(ODataQueryOptions<Node> queryOptions)
{
Contract.Requires(null != queryOptions, "|400|");
queryOptions.Validate(_validationSettings);
var entitySet = new List<Node>();
foreach(var entity in db.Nodes)
{
if(new AccessManager().HasPermission(entity, Permissions.NodesCanRead))
{
entitySet.Add(entity);
}
}
return Ok<IEnumerable<Node>>(entitySet);
}
GET http://localhost:53422/api/Core/Nodes()?$filter=Name%20ne%20'Root%20Node'&$orderby=Modified,%20Created%20desc,%20Id%20asc&$skip=5&$top=35 HTTP/1.1
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 3.0;NetFx
Accept: application/json;odata=minimalmetadata
Accept-Charset: UTF-8
User-Agent: Microsoft ADO.NET Data Services
Authorization: Basic UXVlc3Rpb246d2hvLXJlYWxseS1wb3N0cy1CQVNFNjQtZW5jb2RlZC1jcmVkZW50aWFscy10by1wdWJsaWMtd2ViLXNpdGVz
Host: localhost:53422
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; odata=minimalmetadata; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
Set-Cookie: biz.dfch.CS.Appclusive.Core.Security.AuthenticationFilters.MultiAuthenticationFilter=0F-DA-54-E4-ED-BC-E0-C1-BF-46-98-B2-61-47-05-09-11-27-97-7A-EC-88-81-AA-B7-54-FE-1B-30-AB-73-D0
DataServiceVersion: 3.0
X-AspNet-Version: 4.0.30319
Persistent-Auth: true
X-Powered-By: ASP.NET
Date: Sat, 27 Feb 2016 13:41:10 GMT
Content-Length: 5826
{
"odata.metadata":"http://localhost:53422/api/Core/$metadata#Nodes","value":[
{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"19","Tid":"22222222-2222-2222-2222-222222222222","Name":"vendace","Description":"vendace is a lurdan for joy purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:51.5430276+01:00","Modified":"2016-02-19T13:05:51.5430276+01:00","RowVersion":"AAAAAAAAjWk="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"21","Tid":"22222222-2222-2222-2222-222222222222","Name":"terrapin","Description":"terrapin is a sporty for spicule purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:52.0860587+01:00","Modified":"2016-02-19T13:05:52.0860587+01:00","RowVersion":"AAAAAAAAjXU="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"23","Tid":"22222222-2222-2222-2222-222222222222","Name":"locally","Description":"locally is a aggrade for ultra purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:52.7470965+01:00","Modified":"2016-02-19T13:05:52.7470965+01:00","RowVersion":"AAAAAAAAjYE="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"25","Tid":"22222222-2222-2222-2222-222222222222","Name":"matins","Description":"matins is a petrosal for swain purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:53.3061285+01:00","Modified":"2016-02-19T13:05:53.3061285+01:00","RowVersion":"AAAAAAAAjY0="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"27","Tid":"22222222-2222-2222-2222-222222222222","Name":"leal","Description":"leal is a varices for aggrade purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:53.9841672+01:00","Modified":"2016-02-19T13:05:53.9841672+01:00","RowVersion":"AAAAAAAAjZk="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"29","Tid":"22222222-2222-2222-2222-222222222222","Name":"batten","Description":"batten is a ultra for avaunt purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:54.6532055+01:00","Modified":"2016-02-19T13:05:54.6532055+01:00","RowVersion":"AAAAAAAAjaU="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"31","Tid":"22222222-2222-2222-2222-222222222222","Name":"ultra","Description":"ultra is a stagnate for jut purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:55.2842416+01:00","Modified":"2016-02-19T13:05:55.2842416+01:00","RowVersion":"AAAAAAAAjbE="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"33","Tid":"22222222-2222-2222-2222-222222222222","Name":"vitellin","Description":"vitellin is a locate for ecbolic purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:55.8562743+01:00","Modified":"2016-02-19T13:05:55.8562743+01:00","RowVersion":"AAAAAAAAjb0="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"35","Tid":"22222222-2222-2222-2222-222222222222","Name":"frag","Description":"frag is a barogram for missal purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:56.4993111+01:00","Modified":"2016-02-19T13:05:56.4993111+01:00","RowVersion":"AAAAAAAAjck="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"37","Tid":"22222222-2222-2222-2222-222222222222","Name":"recoup","Description":"recoup is a oxidase for locate purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:57.3283585+01:00","Modified":"2016-02-19T13:05:57.3283585+01:00","RowVersion":"AAAAAAAAjdU="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"39","Tid":"22222222-2222-2222-2222-222222222222","Name":"rainbow","Description":"rainbow is a proa for lurdan purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:05:58.1964082+01:00","Modified":"2016-02-19T13:05:58.1964082+01:00","RowVersion":"AAAAAAAAjeE="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"41","Tid":"22222222-2222-2222-2222-222222222222","Name":"fro","Description":"fro is a mariner for cleft purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:06:00.028513+01:00","Modified":"2016-02-19T13:06:00.028513+01:00","RowVersion":"AAAAAAAAje0="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"43","Tid":"22222222-2222-2222-2222-222222222222","Name":"melic","Description":"melic is a leaky for espy purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:06:00.7705554+01:00","Modified":"2016-02-19T13:06:00.7705554+01:00","RowVersion":"AAAAAAAAjfk="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"45","Tid":"22222222-2222-2222-2222-222222222222","Name":"peen","Description":"peen is a repel for barogram purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:06:01.5085976+01:00","Modified":"2016-02-19T13:06:01.5085976+01:00","RowVersion":"AAAAAAAAjgY="
},{
"EntityId":null,"Parameters":"{}","EntityKindId":"23","ParentId":"1","Id":"47","Tid":"22222222-2222-2222-2222-222222222222","Name":"lollygag","Description":"lollygag is a baronet for enclasp purposes","CreatedById":"3","ModifiedById":"3","Created":"2016-02-19T13:06:02.0976313+01:00","Modified":"2016-02-19T13:06:02.0976313+01:00","RowVersion":"AAAAAAAAjhI="
}
]
,
"odata.nextLink":"http://localhost:53422/api/Core/Nodes()?$filter=Name%20ne%20%27Root%20Node%27&$orderby=Modified%2C%20Created%20desc%2C%20Id%20asc&$top=20&$skip=20"
}
2016-02-27 14:41:00,120 [8] INFO biz.dfch.CS.Utilities.Logging.LogBase [(null)] <(null)> - Intercepted on: ReaderExecuted :- IsAsync: False, Command Text: SELECT
[Var_4].[Id] AS [Id],
[Var_4].[EntityId] AS [EntityId],
[Var_4].[Parameters] AS [Parameters],
[Var_4].[EntityKindId] AS [EntityKindId],
[Var_4].[ParentId] AS [ParentId],
[Var_4].[Tid] AS [Tid],
[Var_4].[Name] AS [Name],
[Var_4].[Description] AS [Description],
[Var_4].[CreatedById] AS [CreatedById],
[Var_4].[ModifiedById] AS [ModifiedById],
[Var_4].[Created] AS [Created],
[Var_4].[Modified] AS [Modified],
[Var_4].[RowVersion] AS [RowVersion]
FROM [core].[Node] AS [Var_4]
WHERE (([Var_4].[Tid] = @DynamicFilterParam_1) OR (@DynamicFilterParam_2 IS NOT NULL)) AND (([Var_4].[Tid] = @DynamicFilterParam_3) OR (@DynamicFilterParam_4 IS NOT NULL))
/**
* Copyright 2014-2016 d-fens GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.