Relationships with polymorphic and .net webapi


#1

So i have this simple structure where the project model has a DS.hasMany('question', {polymorphic: true'} and i all works fine. The derived types get materilized to the store. The paylod looks like this:

{
     project: 'some name',
     questions:  [
            {
                type: 'someType',
                someProp: 'someValue'
            },
            {
                type: 'someType',
                someOtherProp: 'someValue'
            }
        ]
    }
}

But using .net json serialization it adds type specific information and it mucks up the question array to this:

{
    $type: '.net type',
    project: 'some name',
    questions: {
        $type: '.net base type',
        $values: [
            {
                $type: '.net derived type',
                someProp: 'someValue'
            },
            {
                $type: '.net other derived type',
                someOtherProp: 'someValue'
            }
        ]
    }
}

So it breaks totally. questions is no longer an array but object with type and a values array. What hook do i need to override in the serializer in order to make the questions relation/deserialization work again?


#2

IMHO it will be easier to fix at api level than emberjs. Having worked with. Net myself I can confidently attest to it. You can return json of your format. Are you using mvc webapi?