Silverlight Data Access

I am working on a Silverlight reporting tool that draws all kinds of graphical charts based on customer data. The problem I'm currently facing is a good way to get all the data I need from the database into my silverlight application.

Sofar I have a web service that breaks my data into groups of 1000 and returns them to me. I need a little over 3,000 entries, which requires about 4 web service calls in 2 seconds. Needless to say, this is slower than I would like.

I currently have this set:


binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;

I'm sure someone has a better way to get db data faster. At least a way that would allow me to get all my data in one try.

+3
source share
1 answer

This (partly based on an earlier question ) sounds like a bandwidth issue; I would seriously think about trying a protobuff network; the protocol buffer format developed by Google is very efficient ( much larger than the default DataContractSerializer), and it can be very conveniently used from .NET. Ideal for bandwidth related scenarios. The only glitch is that WCF hooks currently do not work with Silverlight (so you cannot just add an attribute / configuration record), but you can easily pass data as byte[](just return byte[]from the method).

For example; if you have an entry like:

[ProtoContract]
public class MyRecord {
    [ProtoMember(1)]
    public int Id {get;set;}

    [ProtoMember(2)]
    public string Description {get;set;}

    // etc
}

a List<MyRecord>, :

byte[] result;
using(MemoryStream ms = new MemoryStream()) {
    Serializer.Serialize(ms, list); // or maybe (list, ms) ;-p
    result = ms.ToArray();
}

, - Stream ( byte[])), , , MTOM (: MTOM, , ).

+1

Source: https://habr.com/ru/post/1718323/


All Articles