ASP.NET Hosting

Fabrice's weblog

Tools and Source

  • Solving URL rewriting problems with themes and trailing slashes

    In a comment to an old post of mine about URL rewriting, a visitor named Tim has just asked how to solve a problem he was facing with ASP.NET themes and rewriting. The original post was addressing the main problems by using an overload of the RewritePath method introduced by .NET 2. Yet, a simple problem still existed: whenever URL rewriting is used with a URL like ~/somepath/ the theme gets broken because the path to the CSS files and other themed resources (like images) are wrong. The problem here is the trailing slash, which confuses the theme engine. A URL like ~/somepath works fine of course.

  • Linq to Amazon source code

    A while ago, I announced Linq to Amazon and started to describe how it's implemented.  Actually producing some content for the book and summer holidays kept me busy for a while, but here is finally the last part of this series of posts.

    In the previous post, I said that what had to be done to create the Linq extension is to implement the IQueryable<T> interface, and write the code that converts an expression tree into an Amazon query.
    What I have done is just a quick and dirty implementation. The goal is not to provide a complete solution to query Amazon using Linq, but instead to create an example to give you an idea of how the Linq extensibility stuff works. As you will see by looking at the source code, a lot of work would be required for a complete implementation.

    Let's describe what you'll find in the source code.

    The BookSearch class implements IQueryable<Book>. This interface speaks for itself. An object that implements it can be queried for Book objects! A BookSearch instance is what we'll query. Our queries start with code like the following:
    var query =
      from book in new Amazon.BookSearch()
      ...

    The important method to look for in the BookSearch class is CreateQuery<S>. This method receives an argument of type Expression. This is our expression tree. All that the CreateQuery<S> method does is creating and returning a new instance of the BookQuery class, passing the expression tree to its constructor.

  • Parsing WordML using Linq to XML

    Eric White, Programming Writer for XLinq, MSXML, and XmlLite, shows how he used Linq to XML (XLinq) to query Word documents.

    This is good example to get an idea of where Linq will help us. Linq comes with a set of features that greatly simplify the code needed to manipulate XML documents, either for querying them or for creating them.

    Eric's post comes with the complete source code. I suggest you take a look at it so you can quickly make your own idea on Linq to XML.
    You may also read this post by Steve Eichert, which highlights major improvements provided by Linq to XML.

    Cross-posted from http://linqinaction.net

  • Why LINQ will succeed

    In the official Linq forum, Joe Albahari presents the reasons why he thinks Linq will succeed:

    1. LINQ syntax beats SQL syntax. SQL is flawed in that queries become exponentially difficult to write as their complexity grows. LINQ scales much better in this regard. Once you get used to it, it's hard to go back.
    2. Database queries are easily composable. You can conditionally add an ORDER BY or WHERE predicate without discovering at run-time that a certain string combination generates a syntax error.
    3. More bugs are picked up at compile-time.
    4. Parameterization is automatic and type-safe.
    5. LINQ queries can directly populate an object hierarchy.
    6. LINQ to SQL provides a model for provider independence that might really work.
    7. LINQ significantly cuts plumbing code and clutter. Without sweeping stuff under the carpet, like Workflow or Datasets. This is a credit to the design team.
    8. C# hasn't suffered in the process (in fact, it's gained).
    There are some bugs in the PDC – also some obstacles to implementing MetaModel and IDbContext without reverse engineering, but nothing unfixable. Looking forward to the release!
    I agree. Great summary.

    Cross-posted from http://linqinaction.net