0

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.

trees_are_great
  • 3,881
  • 3
  • 31
  • 62
  • First of all you should isolate the problem. You'remixing Web API, JSON serialization, and EF/LINQ to Entities in your question. I think all the problem lies in the EF/L2E part. You should test it, and, if the problem is there, update your answer, and your tags, to reflect it. – JotaBe May 15 '15 at 23:09
  • Great idea. Will do! – trees_are_great May 18 '15 at 08:35
  • The problem appears to be a mix of all technologies listed - see the comments added to the bottom of the question – trees_are_great May 18 '15 at 09:19
  • 1
    No, it can not be a mix. Something particular must fail. Please, move the return value to a variable, including a `.ToList().AsNoTracking()` at the end. Then return it. If converting to list works, the problem is in the serializer. If not, it's on Sybase ASE – JotaBe May 18 '15 at 09:34
  • Thanks! See edit - the problem is Sybase ASE. I imagine the problem is actually with the connector? Although neither connectors that I tried work. If so, I will raise a ticket with one of the connector providers. Unfortunately, I cannot tag this question with Sybase-dataconnector or Progress-dataconnector – trees_are_great May 18 '15 at 10:09

0 Answers0