locked
Creating an object graph ... is not in the pocket RRS feed

  • Question

  • Hy,

     

    I've the following Model:

    • an entity FeedItem has
      • one to many <Category>
      • one to many <Response>

    I want to create a new FeedItem on an Astoria Client XBAP :

    • I create a new FeedItem instance
    • Make the DataBinding
    • Let the user set the data and the Categories

     

    I've got an NullReferenceException when i run feedItem.Catagories.Add( myNewCategoty ).

     

    I went into the code (Reflector...No substitute Surprise) and i realize that my detached FeedItem entity has a

     "Categories" property of type WebDataCollection<Category> whith no internal "Context" property set.

    Running the code feedItem.Catagories.Add( myNewCategoty ) make a call on this context -> end.Context.StateManager.AddAssociation(end.Owner, obj, this._navProperty); what raise the NullReferenceException.

    The only way to get an WebDataCollection<T> with a Context set is via JsonDeserializer....

    Question-1: am i rigth or did i miss something.

     

    As a little bug never stop guy like us, i decided to set a custom method NewFeedItem() on the Astoria service side.

    I know this not the best pattern but running CPT requires some "sacrifices"...

    so i try this :

     

    [WebGet]
    public static IEnumerable<MyModel.FeedItem>  NewFeedItem(MyModel.Entities model )
    {
        MyModel.FeedItem item = MyModel.FeedItem.CreateFeedItem( NULL_ID, "", "", "", DateTime.Now);
        CopropertyModel.FeedItem[] items = new CopropertyModel.FeedItem[] { item };
        return items;
    }

    i've got HTTP 500 - Internal server error.

    Question-2: What is the problem ?

    Pablo's doc says, i can return an IEnumerable<T> where T is EntityObject.

    Using detached instance is it making a difference ?

     

    Regards

     

    Thursday, November 15, 2007 12:09 PM

Answers

All replies