SQL Server 2008 slow query on fulltext indexed column

Experienced a very strang issue with a query after upgrading to SQL Server 2008 from 2005.  A query that took less than one second on SQL 2005 ended up taking 27 seconds on SQL Server 2008. 

Exact scenario:

Query that selects data and one of the columns in the select list belonged to a full text index.  If this column is not in the select list, the query runs in under one second.
Removing the full text index did not make a difference
Changing the data type from nvarchar(max) to nvarchar(3000) did not make a difference
adding a where filter of column != '' worked

Not sure why this happened and only in SQL 2008 but not in 2005 but if you are seeing the same issue, I hope this article helps.

LINQ to SQL dynamically set order by

Often I find the need to dynamically specify the order by for a LINQ to SQL query.  I came across a very nice example of this here

I needed to use this technique with a CSLA class, so I needed to call it in a sligthly different manner than the way explained in the article.  I was grouping information and needed to then dynamically set the order by and finally place the results into a CSLA read only list.

I accomplished this as follows:

  1. First I specified my LINQ query and selected the results into an annonymous type and placed into a variable (var data = ...)
  2. Next, called my OrderBy extension method on the LINQ query created in #1

    var ordered = data.OrderBy(criteria.OrderByProperty, criteria.OrderByDesc);


    The criteria object is the typical pattern used in CSLA to pass data to your data access methods such as fetch.
  3. Finally, I selected the data elements into my CSLA list item, and add to the parent list object

    var selected = ordered.Select(a => MyCslaListItem.GetMyCslaListItem(a.Id, a.Name, a.Email, ...));
    this.AddRange(selected);

I understand I could do this in fewer steps, but am leaving as it to explicitly outline the approach taken.

 

 

Generating a valid RSS feed using SyndicationFeed and Rss20FeedFormatter

If you are using the .NET Rss20FeedFormatter and SyndicationFeed classes to generate an RSS feed, you may run into an issue of needing to include a link attribute to the channel element.  If you validate the default RSS generated the validation will fail since the channel element does not contain a link attribute.

You can test this by going to http://beta.feedvalidator.org and entering your feed Url.  If you recieve the error

Missing channel element: link

you can modify your code as follows:

 

SyndicationFeed syndicationFeed = new SyndicationFeed(synicationItems);
syndicationFeed.AttributeExtensions.Add(new XmlQualifiedName("link"), "http://yoursite.com");

 

This will produce a valid RSS feed with a channel that contains a link attribute.