Varchar, Nvarchar and Entity Framework

Further to my previous post about a bug with Entity Framework 1.0, I’ve have discovered another bug but this time due to its handling of varchars.

Let’s assume we’re using the following query:

var query = context.Orders.Where(o => o.Customer.Address.Country == "Australia");

If our Country column is a varchar Entity Framework will pass through our “Australia” string as an nvarchar parameter regardless of what we define in our SSDL!
Now has is this a bad thing you may ask? Well what this means is that even if we have an index on our country column, SQL Server will have to do an index scan rather than an index seek because it has to convert the nvarchar “Australia” down to a varchar and do the comparison across every row in the table.

Thankfully there is a workaround .

This problem has also been addressed in EF 4.0 as well.

Posted in .Net, C#, Sql Server at September 23rd, 2010. No Comments.

Quick WPF Performance Statistics

Just thought I’d put out some quick WPF performance statistics thanks to Microsoft. You can download the entire slideshow here.
  • DependencyProperty is x3 faster than INotifyPropertyChanged
  • ObservableCollection accesses single items 90 times faster than List
  • ObjectDataProvider is x20 smaller than XmlDataProvider

Microsoft also have some other good tips over here too.
I’d like to see some real world statistics on the differences between using static vs dynamic resources too. Anybody know of any?

Posted in .Net, C# at December 23rd, 2009. 1 Comment.

Quickduck logo