This question is locked. New answers and comments are not allowed.
Hi guys - I am getting the following exception when trying to use your OA ORM against Oracle (a wcf data service project)
if I query the entire entity (all properties) without projecting the results (EntitySet.Where(w=>w.Id== "123456") things are working fine. But if I try to project the results into an anonymous type such as EntitySet.Where(w=>w.Id== "123456").Select(w=> new {w.Name}) I get the exception below.
Unable to cast object of type 'System.Object[]' to type 'OpenAccessRuntime.DataObjects.query.Node
From what I am reading on your forums, there was a similar problem with previous version of OA.
However, I am running version 2011.1.411.2 .
Could you please advise how to go about resolving the issue?
G.
if I query the entire entity (all properties) without projecting the results (EntitySet.Where(w=>w.Id== "123456") things are working fine. But if I try to project the results into an anonymous type such as EntitySet.Where(w=>w.Id== "123456").Select(w=> new {w.Name}) I get the exception below.
Unable to cast object of type 'System.Object[]' to type 'OpenAccessRuntime.DataObjects.query.Node
From what I am reading on your forums, there was a similar problem with previous version of OA.
However, I am running version 2011.1.411.2 .
Could you please advise how to go about resolving the issue?
G.
6 Answers, 1 is accepted
0
Hi G.,
Thomas
the Telerik team
I tried to reproduce this here but had no success. What is the column type involved? Also, you could try to leave out the anonymous type from the projection, e.g. .Select(w => w.Name) .
Kind regards,Thomas
the Telerik team
0
Mike Henders
Top achievements
Rank 1
answered on 09 May 2011, 07:24 PM
I too have just started wrapping OpenAccess with a WCF Data Service and am receiving the same error. I can reproduce it by sending oData formatted queries through my browser.
The object being queried looks roughly like this. In reality it is a partial class generated by OpenAccess. The DataServiceKey was added by me because OpenAccess doesn't generate EntityFramework types.
[DataServiceKey("CreativeOID")]
public class Creative {
public string MimeType { get; set; }
public int Height {get; set; }
public int Width { get; set; }
public int CreativeOID { get; set; }
public int CreativeTypeOID { get; set; }
public int CampaignOID { get; set; }
public byte[] Data { get; set; }
}
The query http://localhost:12345/Services/MyDataService.svc/Creatives?$filter=... works correctly with a variety of different filters. However, http://localhost:12345/Services/MyDataService.svc/Creatives?$select=CreativeOID returns:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-CA">An error occurred while processing this request.</message>
<innererror>
<message>An exception occured during the execution of '
Extent<Alaris.CampaignManager.Models.Creative>.Select(p => IIF((p == null), null, new ProjectedWrapper1() {ResourceTypeName = "Alaris.CampaignManager.Models.Creative", PropertyNameList = "CreativeOID", ProjectedProperty0 = Convert(Convert((p As Creative).CreativeOID))}))'. See InnerException for more details.
</message>
<type>System.InvalidOperationException</type>
<stacktrace> at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)
at Telerik.OpenAccess.Query.ExpressionExecution.PerformDatabaseQuery[T](Piece`1 piece, Object[] grpVals)
at Telerik.OpenAccess.Query.Piece`1.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Services.Internal.ProjectedWrapper.EnumerableWrapper.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
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>
<internalexception>
<message>Unable to cast object of type 'System.Object[]' to type 'OpenAccessRuntime.DataObjects.query.Node'.</message>
<type>System.InvalidCastException</type>
<stacktrace> at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQueryImpl(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)
at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)</stacktrace>
</internalexception>
</innererror>
</error>
I want to use the select system query option to avoid sending the data across the wire when the client doesn't want it.
Cheers,
Mike
The object being queried looks roughly like this. In reality it is a partial class generated by OpenAccess. The DataServiceKey was added by me because OpenAccess doesn't generate EntityFramework types.
[DataServiceKey("CreativeOID")]
public class Creative {
public string MimeType { get; set; }
public int Height {get; set; }
public int Width { get; set; }
public int CreativeOID { get; set; }
public int CreativeTypeOID { get; set; }
public int CampaignOID { get; set; }
public byte[] Data { get; set; }
}
The query http://localhost:12345/Services/MyDataService.svc/Creatives?$filter=... works correctly with a variety of different filters. However, http://localhost:12345/Services/MyDataService.svc/Creatives?$select=CreativeOID returns:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-CA">An error occurred while processing this request.</message>
<innererror>
<message>An exception occured during the execution of '
Extent<Alaris.CampaignManager.Models.Creative>.Select(p => IIF((p == null), null, new ProjectedWrapper1() {ResourceTypeName = "Alaris.CampaignManager.Models.Creative", PropertyNameList = "CreativeOID", ProjectedProperty0 = Convert(Convert((p As Creative).CreativeOID))}))'. See InnerException for more details.
</message>
<type>System.InvalidOperationException</type>
<stacktrace> at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)
at Telerik.OpenAccess.Query.ExpressionExecution.PerformDatabaseQuery[T](Piece`1 piece, Object[] grpVals)
at Telerik.OpenAccess.Query.Piece`1.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Services.Internal.ProjectedWrapper.EnumerableWrapper.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
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>
<internalexception>
<message>Unable to cast object of type 'System.Object[]' to type 'OpenAccessRuntime.DataObjects.query.Node'.</message>
<type>System.InvalidCastException</type>
<stacktrace> at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQueryImpl(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)
at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)</stacktrace>
</internalexception>
</innererror>
</error>
I want to use the select system query option to avoid sending the data across the wire when the client doesn't want it.
Cheers,
Mike
0
G.
Top achievements
Rank 1
answered on 09 May 2011, 07:47 PM
Mike - This is precisely what I am experiencing as well. Maybe I confused things a bit by mentioning the anonymous class. All that does is generates a DataService query with $select list of properties that I need returned (a subset of the actual class properties). So whenever the $select keyword is used in the URI query I get the mentioned exception.
Thomas - To adequately repro the issue, you'll need to create a WCF Data Service that sits on top of a DataContext created by running your OpenAcess-> Add Domain Model Wizard (or just use the project template). Then when you issue a DataService URI query (against the service) containing the $select<list of properties to return> you should get the exception that Mike and I mentioned.
I am not sure if this is of any significance or not for your testing, but my Models (OA generated) are in a separate Class Library project that the Service Project references.
PS. Thomas - The type of the requested property does not appear to matter - just tested it with String, DateTime and Long - same exception every time. It is at least consistently failing :)
Thomas - To adequately repro the issue, you'll need to create a WCF Data Service that sits on top of a DataContext created by running your OpenAcess-> Add Domain Model Wizard (or just use the project template). Then when you issue a DataService URI query (against the service) containing the $select<list of properties to return> you should get the exception that Mike and I mentioned.
I am not sure if this is of any significance or not for your testing, but my Models (OA generated) are in a separate Class Library project that the Service Project references.
PS. Thomas - The type of the requested property does not appear to matter - just tested it with String, DateTime and Long - same exception every time. It is at least consistently failing :)
0
Hi G.,
Thomas
the Telerik team
I can reproduce this now. Looks like the DataServices create a certain kind of projection that our LINQ does not support yet; I will work on that, maybe a fix is not that difficult.
Regards,Thomas
the Telerik team
0
0
G.
Top achievements
Rank 1
answered on 20 Jun 2011, 02:11 PM
Thank you for following up Thomas, looking forward to the new release.