Thursday, May 17, 2012

Wcf Data Service fails selecting more than 8 properties (Columns) 'in select ($select) Query

This problem is caused because the way Microsoft and Oracle handles Empty String.  To solve this problem all you need to set "HandleNullStringsAsEmptyStrings = true" of oracle data driver as suggested by Devart team
Problem in detail
If you are developing WCF Data Service using Devart Data Driver and try to select more than 8 columns (properties ) in $select query it throws a null 

Stack Trace 
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <error xmlns="">
  <code />
  <message xml:lang="en-US">An error occurred while processing this request.</message>
  <message>Value cannot be null. Parameter name: value</message>
  <stacktrace>at System.Data.Services.WebUtil.CheckArgumentNull[T](T value, String parameterName) at System.Data.Services.Internal.ProjectedWrapper.set_PropertyNameList(String value) at lambda_method(Closure , Shaper ) at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper) at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext() at System.Data.Services.Internal.ProjectedWrapper.EnumeratorWrapper.MoveNext() at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService) at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description) at System.Data.Services.DataService`1.HandleRequest()</stacktrace>

Just add one line in the service initialization code. 
public static void InitializeService(DataServiceConfiguration config)
//  ….. Other code
            Devart.Data.Oracle.Entity.OracleEntityProviderServices.HandleNullStringsAsEmptyStrings = true;

Root Cause 
This problem is combination of two issue , 
  1. WCF Runtime resolved projections ($Select) differently for more than 8 columns
  2. Oracle treats empty strings in varchar columns as null


No comments:

Post a Comment