Question

I am involved in development of a tiered application that uses LINQ2SQL separated from the web server with a NET.TCP Binding on WCF.

My questions are:

  1. What sort of measures should I take to achieve the best performance?
  2. Since the entity objects returned by the LINQ need to be converted to a IEnumerable list to be serialized everytime, is there anyway to remove this dependency?
Was it helpful?

Solution

1) Concentrate on a properly normalized database design. I would say that when you are forced to make design tradeoffs in your code vs. database design, if performance is your goal, make tradeoffs in your object design instead of your database design. Understand that you aren't going to be able to do a proper supertype/subtype database design which will work with Linq to SQL (I'm told you need to use the EF instead).

2) Depends what you mean here. If you're asking how you would serialize anonymous classes across the wire, the easy answer is: "you can't, so don't try". If you want to put lists of objects across the wire, just use the ToArray() extension method on your IEnumerable collections to ship arrays of your business objects over the wire.

OTHER TIPS

Linq to SQL is very slow unless you compile queries. Otherwise your application will be CPU bound as most of the time will be spend converting Expression trees into SQL.

We are talking about 10x performance gain if you use compiled queries. Try it :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top