ASP.NET Hosting


Archives / 2006 / July
  • 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

  • Sandcastle, Microsoft's replacement for NDoc

    Microsoft listened to our requests. It has announced its upcoming tool for generating MSDN-like documentation from your .NET code. The codename is Sandcastle and the tool is presented as a "Documentation Compiler". It should work the same way NDoc does, except it will support .NET 2.
    The first release has been delayed and is now planned for August, as part of the next CTP release of the Visual Studio SDK.

  • Static method reflection

    .NET reflection features are powerful and this is really what makes it a powerful platform. We don't use reflection everyday, but when we do it's really useful.
    Don't you hate it though when you have to write code like this?:

    MethodInfo method = typeof(MyClass).GetMethod("MyMethod");

    The problem with this code is that we use a string to identify the method, which means that we don't get compile-time validation.
    Ayende has an interesting approach to this problem. He gives you a solution that allows writing the following code instead:

    MethodInfo method = GetMethod<int, string>(MyClass.MyMethod);

    In this case, everything is strongly-typed and checked by the compiler.

    Of course, nothing is perfect and this solution suffers from a number of limitations, but it's an interesting approach anyway. The limitations:

    • it works only with static methods,
    • the methods need to be accessible (public or in your code's reach),
    • we can't use a similar approach for properties.
    Maybe one day we'll get support for this right from the compiler. Currently, there is typeof for types, but we are out of luck for methods, properties or parameters...

    Update: Daniel Cazzulino has another option that is more complete.