www.planet-xaml.net
 
  • Rick Strahl has a nice summary of the various options, in which scope to hold a Linq to SQL DataContext. The per request solutions is the logical choice. In the context of Domain Driven Design there might be another option, namely a DataContext per aggregate root, but this is another topic.

    A lot of code there... even though this is partly due to the fact that it attempts to work per thread or per web request in either case.

    Things get so much easier when you employ an inversion of control container. The DataContext becomes more or less an implementation detail of the repository interfaces and the per request lifecycle is just taken care of. Castle windsor and a little bit of configuration can realy help you get rid of a lot of boiler plate code here.

    XAMLcastle.configtoggle
    <configuration>
      
    <components>
        
    <component id="repositoryProvider"
                   
    type="Kruesch.Data.Repositories.LinqRepositoryProvider, Kruesch.Core"
                   
    service="Kruesch.Services.IRepositoryProvider, Kruesch.Core"
                   
    lifestyle="PerWebRequest"
        
    >
          
    <parameters>
            
    <connectionStringName>SiteDbConnection</connectionStringName>
          
    </parameters>
        
    </component>
      
    </components>
    </
    configuration>

    Be careful to dispose the DataContext at the end of the request in order to close the database connection:

    C#toggle
    public class LinqRepositoryProvider : IRepositoryProvider, IDisposable
    {
       private DomainDataContext _dc;

       
    // c'tor
       public LinqRepositoryProvider(String connectionStringName)
       {
           String connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
           _dc = CreateDataContext(connectionString);
       }

       ...

       
    // Factory method, provice a repository implementation
       public ISharedItemsRepository GetSharedItemsRepository()
       {
           return new SharedItemsRepository(_dc);
       }

       
    // DON'T FORGET THIS
       public void Dispose()
            {            
                if (_dc != null)
                {
                    _dc.Dispose();
                    _dc = null;
                }                        
            }
    }

    Cheers,
    Florian


    no comments
  •  ^
  • [ArchitectureTDD]

    Unity, na endlich

    by Florian Krüsch, February 14, 2008

    Seit vorgestern ist unter dem Namen Unity eine CTP Version des "Dependency Injection Application Block" der Patterns & Practices verfügbar. Es ist zwar sicher noch zu früh, Castle Windsor dafür in die Ecke zu legen, aber es ist wie auch ASP.net MVC ein Zeichen dafür, dass die Technologie in eine gute Richtung geht. Inversion of Control bedeutet losere Kopplung, bessere Testbarkeit und Wartbarkeit.

    Interessant wird es insbesondere im Zusammenhang mit Prism, dem "WPF Composite Application Block" und der neuen Enterprise Library, die alle auf auf IoC aufsetzen. Pattern wie Model View Presenter lassen sich damit wesentlich eleganter in Anwendungen integrieren.

    cheers,
    Florian


    no comments
  •  ^
  • [BlendXAML]

    Will Caligari Truespace 3D become Expression 3D?

    by Florian Krüsch, February 16, 2008

    Microsoft acquires Caligari, the makers of the 3D modelling package trueSpace 3D. According to the sources, Microsoft will integrate it with Virtual Earth somehow.

    In my opinion, it would be kind of sad if TrueSpace would end just as a competitor to Google's Sketchup. Sure, that makes sense, but the real potential would be integrating it with Expression Studio or possibly XNA.

    There are exporters out there that convert 3D scenes to XAML, but I haven't seen the real thing so far. My guess is that we will see a paradigm shift towards 3D user interfaces, but today building them is really hard.

    cheers,
    Florian


    no comments
  •  ^
  • [SilverlightMIX08]

    Silverlight Challenge - Silverglobe

    by Florian Krüsch, February 18, 2008

    SilverGlobe ist Gewinner der deutschen Ausscheidung der European Silverlight Challenge! Okay, da die Teilnehmerzahl nicht wirklich übermässig war, ist das noch kein grosser Verdienst, dennoch bin ich froh dass sich die Mühe gelohnt hat. Mal sehen, ob es für Europa und eine Reise zur MIX 08 reicht.

    SilverGlobe ist eine Silverlight 1.1 Library, die einen interaktiven Globus in 3D darstellt, der sich frei in alle Richtungen drehen lässt. Markierungen können an geographischen Positionen platziert werden.

    Wählt man einen Ort aus, wird dieser zentriert und der Globus richtet sich wieder entlang der Erdachse aus. Dazu gibt es eine kleine Beispielanwendung. Hinter all dem steckt relativ komplizierte 3D Mathematik.

    Zum Download geht es hier. Sobald Silverlight 2.0 verfügbar ist, werde ich das Projekt noch etwas anpassen und auf CodePlex verfügbar machen.

    Cheers,
    Florian


    no comments
  •  ^
  • [DLRIronRuby]

    Videos for Compiler Geeks

    by Florian Krüsch, February 20, 2008

    Ever since programming Z80 assembler in the 80s I've been a compiler/language geek. Ironically, one of the two tests still missing for my Bachelor Degree is Compiler Construction. I will never finish this, because there's always a next project coming along.

    Anyway, if you're also a compiler geek, make sure to check out the videos of the talks at the 2008 Lang.NET symposium. Very interesting stuff. I hope I'll find some time soon to play with some of the stuff presented there, especially Irony and the DLR. And yes, the video player is done in Silverlight.

    Also interesting: the plan to add Dynamic lookup to C# vNext. And what the hell is Microsoft up to with model driven development in Oslo?

    Cheers,
    Florian


    no comments
  •  ^
  • [SilverlightMIX08]

    MIX'08 here I come

    by Florian Krüsch, February 21, 2008

    I just received an email from Jose, telling my that I won a trip to MIX'08 for my participation in the 1st European Silverlight Challenge. Awesome!

    Congratulations to Dejan Anevski, who won the 1st prize and Radenko Zec, 3rd, I'm looking forward to meet you guys at MIX!

    cheers,
    Florian


    3 comments
  •  ^
  • [Silverlight]

    Neue Controls in Silverlight 2 Beta1

    by Florian Krüsch, February 26, 2008

    Koen Zwikstra veröffentlich auf seinem Blog eine Liste der Controls, die in Silverlight 2.0 Beta 1 zu finden sein werden. Quelle ist ein Blog Post von Shwan Burke.

    Shwan hatte offenbar etwas voreilig einen Screenshot aus der VS Control Toolbox für Silverlight veröffentlicht und zwischenzeitlich wieder entfernt. Koen konnte den Screenshot aber retten:
    http://www.firstfloorsoftware.com/images/image_4.png

    Wie Koen bemerkt, sind drei Dinge bemerkenswert:

    • Controls, die in WPF auf Popups basieren, fehlen.
    • Das MultiScaleImage gibt es in WPF nicht. Allerdings gibt es in Flash soetwas ähnliches (Scale9 Grid).
    • Das DataGrid ist wirklich da!

    cheers,
    Florian


    no comments
  •  ^
 

Language | Sprache

All[e]  |  english  |  deutsch
Tags
 

Profile

Florian Kruesch

I am working as a freelance software architect, developer and consultant in Düsseldorf, Germany.

My focus is on Microsoft technologies and .NET 3.0, especially WPF, ASP.net and SQL Server.

I've been a lead programmer on the WPF development of the OTTO Vista Store at SinnerSchrader Studios.

My client list includes DHL, LG and Ogilvy Interactive.