Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 9f43eb3

Browse files
author
Ihar Yakimush
committed
adjust namespaces add tests
1 parent c400ac9 commit 9f43eb3

File tree

8 files changed

+42
-9
lines changed

8 files changed

+42
-9
lines changed

Community.Data.OData.Linq.xTests/FilterNavigationLinkTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
using Community.OData.Linq.xTests.SampleData;
77

8+
using Microsoft.OData;
9+
810
using Xunit;
911

1012
public class FilterNavigationLinkTests
@@ -17,5 +19,11 @@ public void WhereNav1()
1719
Assert.Single((IEnumerable) result);
1820
Assert.Equal(21, result[0].Id);
1921
}
22+
23+
[Fact]
24+
public void WhereNavThrowException()
25+
{
26+
Assert.Throws<ODataException>(() => ClassWithLink.CreateQuery().OData().Filter("Link2/Id eq 211"));
27+
}
2028
}
2129
}

Community.Data.OData.Linq.xTests/OrderByTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ public void OrderByIdDefault()
3131
Assert.Equal(1, result.Id);
3232
}
3333

34+
[Fact]
35+
public void OrderByIdCaseInsensitiveDefault()
36+
{
37+
var result = SimpleClass.CreateQuery().OData().OrderBy("id desc,name").First();
38+
39+
Assert.Equal(2, result.Id);
40+
}
41+
42+
[Fact]
43+
public void OrderByIdCaseSensitiveConfig()
44+
{
45+
Assert.Throws<ODataException>(
46+
() => SimpleClass.CreateQuery().OData(s => s.EnableCaseInsensitive = false).OrderBy("id desc,name"));
47+
}
48+
49+
3450
[Fact]
3551
public void OrderByNotSortable()
3652
{

Community.Data.OData.Linq.xTests/SampleData/ClassWithLink.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
using System.Linq;
44

5+
using Community.OData.Linq.Annotations;
6+
57
public class ClassWithLink
68
{
79
private static readonly ClassWithLink[] items = new[]
@@ -20,5 +22,8 @@ public static IQueryable<ClassWithLink> CreateQuery()
2022
public string Name { get; set; }
2123

2224
public virtual SimpleClass Link1 { get; set; }
25+
26+
[NotNavigable]
27+
public virtual SimpleClass Link2 { get; set; }
2328
}
2429
}

Community.Data.OData.Linq/Builder/ODataModelBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ public SingletonConfiguration<TEntityType> Singleton<TEntityType>(string name) w
203203
return new SingletonConfiguration<TEntityType>(this, this.AddSingleton(name, entity));
204204
}
205205

206-
207-
208206
/// <summary>
209207
/// Registers an entity type as part of the model and returns an object that can be used to configure the entity.
210208
/// This method can be called multiple times for the same entity to perform multiple lines of configuration.

Community.Data.OData.Linq/Builder/ODataConventionModelBuilder.cs renamed to Community.Data.OData.Linq/ODataConventionModelBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
namespace Community.OData.Linq.Builder
4+
namespace Community.OData.Linq
55
{
66
using System;
77
using System.Collections.Generic;
@@ -10,6 +10,7 @@ namespace Community.OData.Linq.Builder
1010
using System.Linq;
1111
using System.Reflection;
1212

13+
using Community.OData.Linq.Builder;
1314
using Community.OData.Linq.Builder.Conventions;
1415
using Community.OData.Linq.Builder.Conventions.Attributes;
1516
using Community.OData.Linq.Common;

Community.Data.OData.Linq/Builder/ODataConventionModelBuilderExtensions.cs renamed to Community.Data.OData.Linq/ODataConventionModelBuilderExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
namespace Community.OData.Linq.Builder
4+
namespace Community.OData.Linq
55
{
66
using System;
77
using System.ComponentModel;
88

9+
using Community.OData.Linq.Builder;
10+
911
/// <summary>
1012
/// Provides extension methods for the <see cref="ODataConventionModelBuilder"/> class.
1113
/// </summary>

Community.Data.OData.Linq/OdataLinqExtensions.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,22 @@ public static IOrderedQueryable<T> OrderBy<T>(this ODataQuery<T> query, string o
130130
ODataQueryOptionParser queryOptionParser = GetParser(query, entitySetName,
131131
new Dictionary<string, string> { { "$orderby", orderbyText } });
132132

133+
ODataSettings settings = query.ServiceProvider.GetRequiredService<ODataSettings>();
134+
135+
// Workaround for strange behavior in QueryOptionsParserConfiguration constructor which set it to false always
136+
queryOptionParser.Resolver.EnableCaseInsensitive = settings.EnableCaseInsensitive;
137+
133138
var orderByClause = queryOptionParser.ParseOrderBy();
134139

135140
orderByClause = TranslateParameterAlias(orderByClause, queryOptionParser);
136141

137-
ODataSettings settings = query.ServiceProvider.GetRequiredService<ODataSettings>();
138-
139142
ICollection<OrderByNode> nodes = OrderByNode.CreateCollection(orderByClause);
140143

141144
OrderValidator.Validate(nodes, settings.ValidationSettings, edmModel);
142145

143-
IOrderedQueryable<T> result = (IOrderedQueryable<T>) OrderApplyToCore<T>(query, settings.QuerySettings, nodes, edmModel);
146+
IOrderedQueryable<T> result = (IOrderedQueryable<T>)OrderApplyToCore<T>(query, settings.QuerySettings, nodes, edmModel);
144147

145-
return new ODataQueryOrdered<T>(result,query.ServiceProvider);
148+
return new ODataQueryOrdered<T>(result, query.ServiceProvider);
146149
}
147150

148151
private static IOrderedQueryable OrderApplyToCore<T>(ODataQuery<T> query, ODataQuerySettings querySettings, ICollection<OrderByNode> nodes, IEdmModel model)

TODO.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ exception handling
88
+non filterable attributes
99
negative scenarious in unit tests
1010
readme with samples
11-
nuget package
11+
+nuget package
1212
github CI

0 commit comments

Comments
 (0)