1
votes

When invoking a query on the data service I get this error message inside the XML feed:

  <m:error>
    <m:code></m:code>
    <m:message xml:lang="nl-NL">Internal Server Error. The type 'MyType' is not a complex type or an entity type.</m:message>
  </m:error>

When I use the example described here in the article "How to: Create a Data Service Using the Reflection Provider (WCF Data Services)" http://msdn.microsoft.com/en-us/library/dd728281(v=VS.100).aspx it works as expected.

I have created the service in a .NET 4.0 web project. My data context class returns a query object that is derived from the LINQExtender (http://linqextender.codeplex.com/). When I execute the query object in a unit test, it works as expected.

My entity type is defined as:

[DataServiceKey("Id")]
public class Accommodation
{
    [UniqueIdentifier]
    [OriginalFieldName("EntityId")]
    public string Id { get; set; }

    [OriginalFieldName("AccoName")]
    public string Name { get; set; }
}

(the UniqueIdentifier and OriginalFieldName attributes are used by LINQExtender)

Does anybody know if this is a bug in WCF data services or am I doing something wrong?

3
Could you please share your "MyType" from the error message (the C# class definition) and the usage of it (where and how do you reference it). The query you're trying to execute would also help.Vitek Karas MSFT

3 Answers

0
votes

There is a known bug in .NET 4 which is similar to the issue you described (as you obfuscated MyType can't be 100% sure).

From Ptatik Patel (Microsoft):

This is a known issue with the WCF Data Services. As Joe said, to make this work, you need to turn off the proxy generation - pretty bad. Sorry, i don't have a better answer at this point, but its too late to fix this in VS 2010 RTM.

0
votes

You cannot use the type string for the field ID. That is causing the "not a complex type or entity type" error you get. Try using an int, and make sure the int is unique for each entity in your queryable. For instance, you can compute the hash value for your string ID and use that as int ID instead.