LINQ to XML and LINQ to XML with XPath performance review

by Arnold Matusz 4 12 2008

In my post about LINQ to XML - XPath I've mentioned how Microsoft warns about the performance bottleneck when using LINQ to XML with the Extension class from the System.Linq.XPath namespace.

"There is some performance penalty for using these methods. Using LINQ to XML queries yields better performance. So it is only advisable to use such LINQ to XML with XPath queries if and only if your application won't suffer from the slight loss of performance!"
» Continue reading ...

LINQ: Sequence contains no elements

by Arnold Matusz 28 10 2008

The InvalidOperationException: Sequence contains no elements exception is thrown whenever you try to retreive an element from an empty sequence. This generally happens when you call First on an empty sequence. What I think about for this situation is that I'ld need a method which would return null if the sequence is empty and the first object (maybe the only object) in the sequence otherwise.

In this case the call of FirstOrDefault is recomended. Although after a few searches I've found something similar: we could Single or SingleOrDefault instead of First. Calling these methods is almost exactly what First does except ... this will generate another exception if the sequest contains more elements: InvalidOperationException: Sequence contains more than one element. But the convenient factor is that it quietly returns the single element in a sequence, null of the sequence is empty and the above mentioned InvalidOperationException: Sequence contains more than one element. » Continue reading ...

What's hot in ASP.NET 3.5 SP1

by Arnold Matusz 22 10 2008

First of all it's worth mentioning that Microsoft brought enhancements to the ASP.NET AJAX Extensions. Now we can use a History control which allows us to use the back button to navigate back to a state before the last async postback happened.

Then there is Dynamic Data which is a framework that discoveres the data model and determines the UI which is best suited, dynamically, during runtime. This sounds weird but it can be of big help! Ex: When you try to display a DateTime value in a GridView, you can use a <asp:DynamicField ... /> which will automatically print your DateTime value nicely formatted. To achieve this with the Normal <asp:BoundField ... /> you needed to set HtmlEncode="false" and DataFormatString="{0:D}". If your DataField is a simple string, this will render a LiteralControl. Not only do these work in Read-Only mode, this also happens in Edit mode which can big of big help. » Continue reading ...

About Arnold Matusz

Arnold Matusz

My name is Arnold Matusz. I'm a web developer specialized in .NET technologies with a passion for photography and cars.

View Arnold Matusz's profile on LinkedIn

Who's amung us