what I miss in LINQdatasource

ASP.NET SQLDatasource control was for me a super productive tool in the past. There are some small features missing like a more elegant data paging. ASP.NET 3.5 bring a new control LinqDatasource which have great support for data paging. So I tried  to create a rss feed with LINQtoSQL and LinqDatasource. Result is not as I expected.

Caching

SQLDatasource supports data Caching with simply two attributes enablecaching=true and cacheduration=60. Caching makes applications much faster.

Filtering

In combination with  caching SQLDatasource supports filterparameter which allow a kind of offline (from database) filtering. Also makes application faster and reduce load on SQL server.

FilterExpression="ProductName LIKE '@PN%'"

extended where conditions

As in the sample before i miss extended where condition in LINQ querys. The wizzard of LINQdatasource only allow a few expressions like ==.

In pure LINQ querys you can use syntax like

Dim expr = From hannes In kunden.Kundens _
                   Where hannes.City Like "a*" _
                    Select hannes

or even

 Where SqlMethods.Like(hannes.City, "a%") _

Both doesn’t work in LINQdatasource.

Relations

For this point i am not sure if I miss some part. With sqldatasource I usually join data via SQL command. With LINqtoSQL you can define relations but not to handle it virtual as one “table” . With LINQ query's in code that's not a issue. LINQDatasource only allows to select one table so i can not handle the join of normalized data.

 

I am open for discussion at this point.

4 Comments

  • Hannes,

    You can always handle the Selecting event of the LinqDataSource and setting the data object arg.Result available in the LinqDataSourceSelectEventArgs arg to whatever query you want.

    In the example here, I am setting the data object to be a LINQ query that consumes an RSS feed.

    http://weblogs.asp.net/rajbk/archive/2007/09/24/using-the-listview-in-tiled-mode-part-2-css-layout.aspx

    Raj

  • Is there anyway to set the data with other LinqDataSource events rather than LinqDataSourceSelectEventArgs. If I decided to use the DataBind() method on a bound control it will not activate the OnSelecting Event for the LinqDataSource

  • Disregard Last Comment, I forgot to manually add databinding on my pager control, OnSelecting works fine.

  • mL83Om Thanks for sharing, this is a fantastic blog post.Really looking forward to read more. Really Great.

Comments have been disabled for this content.