EntityGraph.Copy on entities with complex type(s) fails

Aug 31, 2011 at 1:51 PM

Hi all,

I'm copying an entity with EntityGraph().Copy() in Silverlight 4 client. It's working fine already on entities without complex types. But as soon a complex type is used in the entity I get following errors:

- When the complex type is not included in the EntityGraph through Edge I get this error: "ComplexObject instances cannot be shared." That's probably normal as these instances belong to their related entities and cannot be re-used on another entity.

- When the complex type is included in the EntityGraph I get this this error: "Unable to cast object of type 'MyComplexType' to type 'System.ServiceModel.DomainServices.Client.Entity'." Also normal imo.

I need these complex types on the client, so I can't exclude them with the Exclude attribute in the metadata class. I also went through the documentation and did some hours of searches on the internet but to no avail.

Has anyone an idea how I could get around these errors? If no solution I'll have to drop the complex types on the entities and refactor a lot of code which is already working with the complex types...

Thx in advance!

Gr,

SsanchezZ23

Developer
Aug 31, 2011 at 7:17 PM

Hi SsanchezZ23,

Thanks for using EntityGraph and for reporting this issue.

I'm sorry to say that ComplexTypes are currently not supported by EntityGraph.

In the current implementation , all nodes in an entity graph (as defined by your graph shape) should be derived from System.ServiceModel.DomainServices.Client.Entity. That is the reason for the second error you get.

I can't give any indication at the moment when ComplexTypes will be supported by EntityGraph.

I'm sorry.

Merijn

Sep 1, 2011 at 7:03 AM

Hi Merijn,

Thx for your quick answer. So I can at least stop searching for a solution for this... I'll refactor the code and drop the complex types (like they're hot).

Keep up the good work!

Gr,

SsanchezZ23