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

Commit c8cf46e

Browse files
author
Ihar Yakimush
committed
not mapped unit tests
1 parent dfc9f18 commit c8cf46e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ public void WhereByNonFilterableThrowException()
114114
() => SimpleClass.CreateQuery().OData(s => s.EnableCaseInsensitive = false).Filter($"{nameof(SimpleClass.NameNotFilter)} eq 'nf1'"));
115115
}
116116

117+
[Fact]
118+
public void WhereByNotMappedThrow()
119+
{
120+
Assert.Throws<ODataException>(
121+
() => SimpleClass.CreateQuery().OData(s => s.EnableCaseInsensitive = false).Filter($"{nameof(SimpleClass.NotMapped)} eq 'nf1'"));
122+
}
123+
117124
[Fact]
118125
public void WhereByIgnoreDataMemberThrowException()
119126
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Community.OData.Linq.xTests.SampleData
55
{
66
using System;
7+
using System.ComponentModel.DataAnnotations.Schema;
78
using System.Linq;
89

910
public class SimpleClass
@@ -35,5 +36,8 @@ public static IQueryable<SimpleClass> CreateQuery()
3536

3637
[NotSortable]
3738
public int NotOrderable { get; set; }
39+
40+
[NotMapped]
41+
public int NotMapped { get; set; }
3842
}
3943
}

Community.Data.OData.Linq/Builder/Conventions/Attributes/NotMappedAttributeEdmPropertyConvention.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Community.OData.Linq.Builder.Conventions.Attributes
55
{
66
using System;
7-
7+
using System.ComponentModel.DataAnnotations.Schema;
88
using Community.OData.Linq.Common;
99

1010
using Microsoft.OData.Edm;
@@ -19,7 +19,7 @@ internal class NotMappedAttributeConvention : AttributeEdmPropertyConvention<Pro
1919

2020
private static Func<Attribute, bool> _filter = attribute =>
2121
{
22-
return attribute.GetType().FullName.Equals(EntityFrameworkNotMappedAttributeTypeName, StringComparison.Ordinal);
22+
return attribute.GetType() == typeof(NotMappedAttribute);
2323
};
2424

2525
public NotMappedAttributeConvention()

0 commit comments

Comments
 (0)