This is a migrated thread and some comments may be shown as answers.

Filter entity on enum property throws error

5 Answers 53 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Masoud
Top achievements
Rank 1
Masoud asked on 21 Mar 2012, 12:11 PM
Hi there,

I am trying to filter using Enum properties and getting an exception.

I want to filter type BasisBaumEntity. The property I would like to filter against is called BewBpflErhaltfaehigKey of type Erhaltfaehigkeit which is an enum (that inherits from byte).  

I am creating the filter programatically: 
FilterDescriptor filterDescriptor = new FilterDescriptor("BewBpflErhaltfaehigKey", FilterOperator.IsEqualTo, Erhaltfaehigkeit.Kurzfristig 

Here is the request as recorded by Fiddler
@
MessageRoot@ QueryOptions@
QueryOptionName�whereValue�9(it.BewBpflErhaltfaehigKey==Erhaltfaehigkeit.Kurzfristig)@
QueryOptionName�orderbyValue�it.Nr@
QueryOptionName�takeValue�24@
QueryOptionName�includeTotalCountValue�True@
GetBasisBaumshttp://tempuri.org/


The exception I receive is 
Property or field "Erhaltfaehigkeit" is not declared in type in "BasisBaumEntity".
I tried to decorate the Enum with [DataContract] attribute, and decorated the members with [EnumMember].  Still, WCF RIA server side ist trying to locate Erhaltfaehigkeit as a field or property in BasisBaumEntity.  

Jeff Handler from the WCF RIA Team states that such filtering should be possible  (http://jeffhandley.com/archive/2010/11/19/DomainDataSourceEnumFilters.aspx).  
If you wish I can send you the stacktrace of the exception!

I would really appreciate you help on this issue!


Best

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 21 Mar 2012, 01:58 PM
Hi,

This really seems like a WCF RIA Services-related  issue and we do not believe that it is connected with Telerik controls. 

RadDomainDataSource uses the WCF RIA DomainContext and EntityQuery API for absolutely everything it does. In other words, it steps on WCF RIA Services -- it does not replace them.

Can you successfully filter on this enum property if you do not use any Telerik controls? For example, you can try with the stock Microsoft DomainDataSource or you can directly use the DomainContext and try to load an EntityQuery.Where(<<filter on the enum prop here>>). 

What are the results? Are they different or are they the same?

Let us know if the stock Microsoft DomainDataSource works successfully and ours does not.

All the best,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Masoud
Top achievements
Rank 1
answered on 21 Mar 2012, 04:26 PM
Hi Ross,

thank you for your reply!

I now managed to test the MS DomainDataSource.  It turns out that DomainDataSource casts Enum values to numeric representations.  Following is the request as captured by Fiddler
@
MessageRoot@ QueryOptions@
QueryOptionName�whereValue�\(it.BewBpflErhaltfaehigKey==0)@
GetBasisBaumshttp://tempuri.org/

Running the same FilterDescriptor against the RadDomainSource the enum values are not cast to a numeric but rather handed over as string:

QueryOptionName�whereValue�9(it.BewBpflErhaltfaehigKey==Erhaltfaehigkeit.Kurzfristig)@ 

This causes an exception with the Domain Service on the server.

Can you please suggest a way to use the RadDomainSource with enums?

Best regards


0
Rossen Hristov
Telerik team
answered on 21 Mar 2012, 04:42 PM
Hi,

Thanks for the information. I will immediately investigate what do we append on the EntityQuery when there is an enum value in the FilterDescriptor.

By the way, do you have any kind of a dummy sample project with dummy data that I can debug in order to see what is going on. I suppose that since you have played around with this issue, you might have some kind of a dummy project that I could use.

All the best,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Rossen Hristov
Telerik team
answered on 21 Mar 2012, 05:27 PM
Hi,

No need to send me anything. I reproduced it. Apparently MS are converting the enum value to int before sending it to the server.

I will try to make RadDomainDataSource do the same and I will contact you when I am ready.

Kind regards,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Accepted
Rossen Hristov
Telerik team
answered on 26 Mar 2012, 09:04 AM
Hi,

I managed to fix the bug.

Unfortunately, the fix will not be able to make it in the Service Pack, since we have a code freeze already. The fix will be released with our first "Latest Internal Build" that will come out after the Service Pack, which I reckon will be in about 5-10 days.

All the best,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
DomainDataSource
Asked by
Masoud
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Masoud
Top achievements
Rank 1
Share this question
or