Web Api Returning Json - [System.NotSupportedException] Specified method is not supported. (Sybase Ase)

677 Views Asked by At

I'm using Web api with Entity Framework 4.2 and the Sybase Ase connector.

This was working without issues returning JSon, until I tried to add a new table.

  return db.car
             .Include("tires")
             .Include("tires.hub_caps")
             .Include("tires.hub_caps.colors")
             .Include("tires.hub_caps.sizes")
             .Include("tires.hub_caps.sizes.units")
             .Where(c => c.tires == 13);

The above works without issues if the following line is removed:

.Include("tires.hub_caps.colors")

However, when that line is included, I am given the error:

""An error occurred while preparing the command definition. See the inner exception for details."

The inner exception reads: "InnerException = {"Specified method is not supported."}" "source = Sybase.AdoNet4.AseClient"

The following also results in an error:

  List<car> cars = db.car.AsNoTracking()
             .Include("tires")
             .Include("tires.hub_caps")
             .Include("tires.hub_caps.colors")
             .Include("tires.hub_caps.sizes")
             .Include("tires.hub_caps.sizes.units")
             .Where(c => c.tires == 13).ToList();

The error is as follows:

An exception of type 'System.Data.EntityCommandCompilationException' occurred in System.Data.Entity.dll but was not handled in user code

Additional information: An error occurred while preparing the command definition. See the inner exception for details.

Inner exception: "Specified method is not supported."

This points to a fault with with the Sybase Ase Data Connector.

I am using data annotations on all tables to control which fields are returned. On the colors table, I have tried the following annotations to limit the properties returned just the key:

[JsonIgnore]
 [IgnoreDataMember]

Any ideas what might be causing this issue?

Alternatively, if I keep colors in and remove,

 .Include("tires.hub_caps.sizes")
 .Include("tires.hub_caps.sizes.units")

then this works also. It seems that the Sybase Ase connector does not support cases when an include statement forks from one object in two directions. Is there a way round this? The same issue occurs with Sybase Ase and the progress data connector.

The issue does not occur in a standard ASP.net MVC controller class - the problem is with serializing two one to many relationships on a single table to JSON.

This issue still occurs if lazy loading is turned on.

It seems to me that this is a bug with Sybase ASE, that none of the connectors are able to solve.

0

There are 0 best solutions below