Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Circular Reference with Complex Type

$
0
0

I have created a webservice that returns a complex type.  This is the xml that is returned from the webservice:

<NinjaRouteEntity xmlns="http://tempuri.org/">
  <Entity NinjaRouteID="1" xmlns="">
    <AlwaysFetchToRegion>False</AlwaysFetchToRegion>
    <TimeFrameReturnsNewIfNotFound>True</TimeFrameReturnsNewIfNotFound>
    <AlwaysFetchFromRegion>False</AlwaysFetchFromRegion>
    <EntityCollectionReference PropertyName="PointCollectionViaNinjaRouteVector">
      <PointCollectionViaNinjaRouteVector>
        <Entities />
        <AllowRemove>False</AllowRemove>
        <AllowEdit>True</AllowEdit>
        <AllowNew>True</AllowNew>
      </PointCollectionViaNinjaRouteVector>
    </EntityCollectionReference>
    <ToRegionReturnsNewIfNotFound>True</ToRegionReturnsNewIfNotFound>
    <EntityReference PropertyName="TimeFrame" />
    <EntityReference PropertyName="FromRegion" />
    <IsNew>False</IsNew>
    <FromRegionReturnsNewIfNotFound>True</FromRegionReturnsNewIfNotFound>
    <AlwaysFetchNinjaRouteVector>False</AlwaysFetchNinjaRouteVector>
    <AlwaysFetchPointCollectionViaNinjaRouteVector>False</AlwaysFetchPointCollectionViaNinjaRouteVector>
    <EntityReference PropertyName="ToRegion" />
    <AlwaysFetchTimeFrame>False</AlwaysFetchTimeFrame>
    <AlwaysFetchSuggestedRouteCollectionViaNinjaSuggestedRoute>False</AlwaysFetchSuggestedRouteCollectionViaNinjaSuggestedRoute>
    <EntityCollectionReference PropertyName="SuggestedRouteCollectionViaNinjaSuggestedRoute">
      <SuggestedRouteCollectionViaNinjaSuggestedRoute>
        <Entities />
        <AllowRemove>False</AllowRemove>
        <AllowEdit>True</AllowEdit>
        <AllowNew>True</AllowNew>
      </SuggestedRouteCollectionViaNinjaSuggestedRoute>
    </EntityCollectionReference>
    <EntityCollectionReference PropertyName="NinjaSuggestedRoute">
      <NinjaSuggestedRoute>
        <Entities />
        <AllowRemove>False</AllowRemove>
        <AllowEdit>True</AllowEdit>
        <AllowNew>True</AllowNew>
      </NinjaSuggestedRoute>
    </EntityCollectionReference>
    <ObjectID>7ba4f8ed-08d5-47cb-9dcc-096725d03d69</ObjectID>
    <EntityCollectionReference PropertyName="NinjaRouteVector">
      <NinjaRouteVector>
        <Entities />
        <AllowRemove>False</AllowRemove>
        <AllowEdit>True</AllowEdit>
        <AllowNew>True</AllowNew>
      </NinjaRouteVector>
    </EntityCollectionReference>
    <AlwaysFetchNinjaSuggestedRoute>False</AlwaysFetchNinjaSuggestedRoute>
    <Fields>
      <NinjaRouteID>
        <CurrentValue>1</CurrentValue>
        <DbValue>1</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </NinjaRouteID>
      <Name>
        <CurrentValue>My Awesomer Route</CurrentValue>
        <DbValue>My Awesomer Route</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </Name>
      <Description>
        <CurrentValue>Go from here to there.</CurrentValue>
        <DbValue>Go from here to there.</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </Description>
      <CreatorID>
        <CurrentValue>4b4a743b-345f-4dd6-905a-bb59708491ed</CurrentValue>
        <DbValue>4b4a743b-345f-4dd6-905a-bb59708491ed</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </CreatorID>
      <DateCreated>
        <CurrentValue>2006-01-31T01:45:34.0000000-08:00</CurrentValue>
        <DbValue>2006-01-31T01:45:34.0000000-08:00</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </DateCreated>
      <FromRegionID>
        <CurrentValue>1</CurrentValue>
        <DbValue>1</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </FromRegionID>
      <ToRegionID>
        <CurrentValue>2</CurrentValue>
        <DbValue>2</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </ToRegionID>
      <TimeFrameID>
        <CurrentValue>2</CurrentValue>
        <DbValue>2</DbValue>
        <IsChanged>False</IsChanged>
        <IsNull>False</IsNull>
      </TimeFrameID>
    </Fields>
    <IsDirty>False</IsDirty>
    <EntityState>Fetched</EntityState>
    <SavedFieldSets />
  </Entity>
</NinjaRouteEntity

When I try to call it with Atlas, I see this error via Fiddler:

new Sys.Net.MethodRequestError("A circular reference was detected while serializing an object of type \'FlatlandMedia.NinjaRoutes.Dal.EntityClasses.NinjaRouteEntity\'.","   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeEnumerable(IEnumerable enumerable)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeCustomObject(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValueInternal(Object o)\r\n   at Microsoft.Web.Script.Serialization.JavaScriptObjectSerializer.SerializeValue(Object o)\r\n   at Microsoft.Web.Services.RestHandler.ProcessRequest(HttpContext context)","System.InvalidOperationException")

Any way around this?  Are there any guidelines as to how complex a type can be?

Thanks for any help on this.


Viewing all articles
Browse latest Browse all 5678

Trending Articles