Ignore properties attribute not working in WCF Data Services 5.0 RTM Release
-
2012년 4월 11일 수요일 오후 4:34
Hi,
As soon as I updated to the 5.0 release I could no longer get IgnoreProperties to work with this simple test...
[System.Data.Services.IgnoreProperties("State")]
public class Tmp
{
public Guid ID { get; set; }
public int Test1 { get; set; }
public TestStateEnum State { get; set; }
}
Followed by the typical error you would expect the ignore attribute to resolve.
The server encountered an error processing the request. The exception message is 'The property 'State' on type 'DomainModel.Tmp' is not a valid property. Make sure that the type of the property is a public type and a supported primitive type or a entity type with a valid key or a complex type.'. See server logs for more details. The exception stack trace is:
at System.Data.Services.Providers.ReflectionServiceProvider.BuildTypeProperties(ResourceType parentResourceType, IDictionary`2 knownTypes, IDictionary`2 childTypes, Queue`1 unvisitedTypes, IEnumerable`1 entitySets) at System.Data.Services.Providers.ReflectionServiceProvider.PopulateMetadataForTypes(IDictionary`2 knownTypes, IDictionary`2 childTypes, Queue`1 unvisitedTypes, IEnumerable`1 entitySets) at System.Data.Services.Providers.ReflectionServiceProvider.PopulateMetadata(IDictionary`2 knownTypes, IDictionary`2 childTypes, IDictionary`2 entitySets) at ...
Any idea what happened in this release?
Thanks!
모든 응답
-
2012년 4월 11일 수요일 오후 5:00중재자
Hi,
I'm working on reproducing this issue locally and will reply back in a few minutes. Thanks for reporting this!
Matt Meehan (WCF Data Services / OData)
-
2012년 4월 11일 수요일 오후 5:01중재자
Hi,
Make sure that the assembly in which the class with the attribute is defined references the new Microsoft.Data.Services assemblies and not the old System.Data.Services assemblies. Otherwise the attributes won't be correctly recognized.
Thanks,
Vitek Karas [MSFT]
- 답변으로 표시됨 BotHead 2012년 4월 11일 수요일 오후 6:19
-
2012년 4월 11일 수요일 오후 6:17
That was exactly it, thanks Vitek! I updated all my references except in the project where my class definition lived.
-
2012년 7월 17일 화요일 오전 11:00
Hi,
Make sure that the assembly in which the class with the attribute is defined references the new Microsoft.Data.Services assemblies and not the old System.Data.Services assemblies. Otherwise the attributes won't be correctly recognized.
Thanks,
Vitek Karas [MSFT]
Hi Vitek,
I've just run into the same issue. I'm trying to work round the problem of enum properties in my code first data model. As a test I create a small class without enums and tried to ignore one or more properties:
using System; using System.Data.Services; namespace WcfServiceApp { [IgnoreProperties("Genre")] public class Book { public int Id { get; set; } public string Title { get; set; } public string Author { get; set; } public int Genre { get; set; } } }I'm referencing EF5.0, Microsoft.Data.Edm 5.0.1, Microsoft.Data.OData 5.0.1, Microsoft.Data.Services 5.0.1 and Microsoft.Data.Services.Client 5.0.1. in my data service class I set:
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
The property is still visible via an OData query and if I use an enum property I get a crash. Any idea what's going wrong?
Thanks.
-
2012년 8월 3일 금요일 오전 2:22
I get the same and this is my properties :
<IgnoreProperties("Localisation")> Partial Public Class t_terr_localisation Public Property CODE_GEO As String Public Property NOM As String Public Property CODE_ENTITE As Nullable(Of Short) Public Property Localisation As System.Data.Spatial.DbGeography End ClassI have no idea why the attribute wont work...
Micael Levesque
- 편집됨 micaël 2012년 8월 3일 금요일 오전 2:25
-
2012년 8월 3일 금요일 오후 1:40중재자
The IgnoreProperties attribute is currently only supported for reflection provider. EF providers doesn't recognize that attribute.
Thanks,
Vitek Karas [MSFT]
-
2012년 8월 6일 월요일 오후 2:59
Hi again,
I advanced with another way, but i did get blocked on registering the distances functions with the data service. The examples given that i ve found on the web are outdated and the system.spatial dll does not contain the same methods anymore :
how do you register now for the distances ?
// Register my operations
SpatialOperations.Register(2.0, new MyOperations());does not exist in spatialOperations class, not on MSDN, no where in fact...
So an example would be appreciated how to use the spatial type with WCF data services thanks!
Micael Levesque
-
2012년 9월 5일 수요일 오후 5:28중재자
Sorry for the delay Micael,
I've made a quick post in the comments for that blog post, but the short answer is:
SpatialImplementation.CurrentImplementation.Operations = new MyOperations();
We forgot to update the CTP blog posts to reflect changes made based on feedback, and didn't make new posts for every feature. We hope to get a new updated blog post soon after our next release.
Matt Meehan (WCF Data Services / OData)

