Click here to Skip to main content
15,896,268 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I'm learning Silverlight. So far, so good. Now I'm building a small Silverlight application that uses webservices to get data from a MSSQL database.

The services gets the data through LINQ, puts it in a result and puts that result in a list with a object class. The idea is that the list is returned and bound to a datagrid.

The data, of the result, is a very large one (9369 records). The service hangs (timeout) while making that list to return.

How can I speed up things?

Thanks in advance.
Posted
Comments
Wonde Tadesse 5-Jul-11 19:44pm    
This is a lack of how to present data in UI. It's not LINQ problem.See answer OriginalGriff properly.

Don't run a query that returns 9369 records to a datagrid?

No, seriously: don't run a query that returns 9369 records to a datagrid.

What do you expect the user to do with that? How long do you think he is going to spend scrolling through before he decides your software is a load of rubbish and goes elsewhere?

Page it - about 20 records is normal. Allow him to search it. Filter it. Save it if you must. But don't just dump it in a grid and walk away!
 
Share this answer
 
Verify your request with LINQPad: http://www.linqpad.net/[^].

Using that tool, you will have an idea how your request is translated into SQL and the time it takes.

Does the data come from a single table or multiple tables? If it come from multiple tables, the first thing to check would be to see if lot of round-trip are made to the server.

And effectively for large tables, you have to uses paging or virtual loading of the data.
 
Share this answer
 
I second the advice to no return 9369 records, use paging. However, I would not use LINQ to access a SQL DB in general, unless your query is incredibly simple. Never use auto generated stuff if you can control it more directly.
 
Share this answer
 
Hi all,

Thanks for replying. The paging was a good idea. I searched google for examples and found something that would work:

1. ADO.NET (so no LINQ, is also easier for me because I can re-use the queries in the old ASP project)
2. Result from the query is send back in a dataset.
3. Export the dataset to XML
4. Send back the XML from the webservice to the Silverlight application
5. In the Silverlight application the XML is put in a list with the object class.
6. Add a DataPager to the usercontrol
7. Put the list XML in a PagedCollectionView
8. Bind the PagedCollectionView to the DataPager and datagrid

Done!

Works like a charm. Loading time is now 1 to 2 seconds.

Thanks for bringing this up!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900