yea! you can build the model on the fly too if you cant annotate the classes


On Sat, Aug 10, 2013 at 5:03 PM, Corneliu I. Tusnea
<[email protected]>wrote:

> Have you had a look at ProtoBuffers what Wal recommended?
> The payload is about 30% smaller and few times faster.
> There is a SL implementation as well:
>
> http://www.codeproject.com/Articles/73901/Silverlight-Binary-Serialization-using-Protobuf-ne
>
>
>
>
> On Sat, Aug 10, 2013 at 6:23 PM, Greg Keogh <[email protected]> wrote:
>
>> Folks, I think I've found a coding pattern that is quite easy for
>> transferring large numbers of entity classes over the wire in one go. The
>> "entities" I'm talking about here were generated by an EDMX, so I'm not
>> free to edit or annotate them with things to assist serialization. Also
>> remember that Silverlight is one of the clients.
>>
>> The XmlSerializer fails to serialize entity collections due to the
>> ICollection navigation properties, and I don't think there is an equivalent
>> to deserialize on the SL client side. This sadly means that XML is not a
>> viable option.
>>
>> Json round-tripping is possible on all ends, and the serializer is
>> surprisingly smart, taking all the classes and property types I've thrown
>> at it so far. So I have decided for now that Json is my way to go, like
>> this:
>>
>> var ser = new DataContractJsonSerializer(typeof(T[]));
>> ser.WriteObject(stream, items);
>>
>> You can turn the stream into a string or deflate the buffer (as I do) to
>> send to clients. Just reverse the process with an inflate and
>> ser.ReadObject on the clients and you get your array back The Json
>> serializer does a lot of the hard work. The total code is quite small,
>> general purpose and it's all built-in to the framework (oops, except the
>> optional deflate processing which I did with Ionic.Zlib which has SL
>> support and is pretty simple).
>>
>> NOTE: This Json pattern is great when the total blob you're sending is
>> reasonably sized for a single request, which is ~600KB in my case for ~6500
>> objects. If sizes blow up much more then it's back to background chunking
>> or paging or async cleverness like the Google search suggestions (how do
>> they do that so fast?)
>>
>> Greg K
>>
>
>

Reply via email to