tisdag 11 september 2012

SQL Server: Update expression when new value is a string with an accented character

If we want to update a string value and the new value has accented characters (e.g. č) one way to accomplish this is, in the SQL expression, to prefix the value with a capital letter 'n'.
For example like so:
UPDATE DB.table
SET Column = N'Količina'
WHERE Id = x

måndag 10 september 2012

WPF: Set a View's ViewModel for Designer to work against

To set a ViewModel for the Designer to work against you can do the following:
To the view's XAML code simply add the namespace to the viewmodel
xmlns:vm="clr-namespace:EOL.ViewModels"
and the following
d:DataContext="{d:DesignInstance Type=vm:ViewModel, IsDesignTimeCreatable=true}"

In the case of project named 'XYZ' with a UserControl as the view in a folder called  'Views' and a viewmodel called 'ViewModel' in the folder 'ViewModels' the XAML would look something like this:

<UserControl x:Class="XYZ.Views.View"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:XYZ.ViewModels"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=vm:ViewModel, IsDesignTimeCreatable=true}">

Note that the viewmodel must have a parameterless constructor for this to work...