Archive for 04:17 PM

Winning The Oil Endgame

04:17 PM

Amory Lovins talks at TED how money can be earned by using technology to reduce oil consumption.

Google Talk Review: Benefits from Open Sourcing Code

02:53 PM

Ben Collins-Sussman and Brian “Fitz” Fitzpatrick talk in this Google Talk about the business reasons behind open sourcing code, as well as how to successfully build a community around the code. In this entry I collected their arguments.

(more…)

WPF: DateTime Format

05:08 PM

Ever wondering why DateTime’s in WPF are formatted the American way? Well, here is the reason why: WPF Tips’n'Tricks #1: Have all your dates, times, numbers… in the local culture

In short:


static App()
{
    FrameworkElement.LanguageProperty.OverrideMetadata(
        typeof(FrameworkElement),
        new FrameworkPropertyMetadata(
            XmlLanguage.GetLanguage(
                CultureInfo.CurrentCulture.IetfLanguageTag)));
}

Entity Framework: EntityReference.IsLoaded

04:01 PM

There is an issue with the Entity Framework Beta 3. If you use the EntityReference Object’s Load() Method and the Result is null then the IsLoaded bit is not set.

This is nasty because the EF will always try to load the Reference from the Database.

Or I made a mistake…

Here is an example:


[EdmRelationshipNavigationPropertyAttribute("Model", "FK_Auftrag_Mitarbeiter", "A_Mitarbeiter")]
public App.Mitarbeiter Mitarbeiter
{
  get
  {
    EntityReferenceMitarbeiter> r =
      ((IEntityWithRelationships)(this)).RelationshipManager
      .GetRelatedReferenceMitarbeiter>
      ("Model.FK_Auftrag_Mitarbeiter", "A_Mitarbeiter");

    if (!r.IsLoaded)
      r.Load();

    return r.Value;
  }
}

Entity Framework: How to embed C/M/S Files

01:12 PM

That’s simple:

  1. Embed your files as a resource in your DLL
  2. In your app.config change the connectionstring from:

<add name="KistlContext"
  connectionString="metadata=.\Model.csdl|.\Model.ssdl|.\Model.msl;
  provider=System.Data.SqlClient;
  provider connection string='Data Source=.\SQLEXPRESS;
    Initial Catalog=YourDatabase;
    Integrated Security=True;
    MultipleActiveResultSets=true;'"
  providerName="System.Data.EntityClient" />

to:


<add name="KistlContext"
  connectionString="metadata=res://*;
  provider=System.Data.SqlClient;
  provider connection string='Data Source=.\SQLEXPRESS;
    Initial Catalog=YourDatabase;
    Integrated Security=True;
    MultipleActiveResultSets=true;'"
  providerName="System.Data.EntityClient" />

It does not matter in which assembly the model is embedded.