* sigh*
Well, as George Costanza once tried, I went for the trifecta using Visual Studio 2005 Beta 2, DLinq, and Avalon (WPF) to create a solution using the LINQWinFXApplication template to no avail. The problem may be that I'm using SQL Server 2000 because the SQL Server 2005 installation that came with VS2005 Beta 2 didn't work out for me the way I hoped and dreamed. I've been able to create a solitary DLinq application using SQL Server 2000 just fine. I can also create an Avalon application...but I can't mix the two. Here's what happens...
<Window x:Class="LINQWinFXApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
Text="Customers">
<Window.Resources>
<DataTemplate x:Key="CustomerTemplate">
<DockPanel>
<TextBlock Width="300" TextContent="{Binding Path=CustomerID}" />
<TextBlock Width="300" TextContent="{Binding Path=CompanyName}" />
<TextBlock Width="300" TextContent="{Binding Path=NumOrders}"/>
</DockPanel>
</DataTemplate>
</Window.Resources>
<DockPanel x:Name="docPanelCustomers">
<ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" ItemTemplate="{StaticResource CustomerTemplate}" />
</DockPanel>
</Window>
using(SqlConnection connection = new SqlConnection("Password=canttellyouthat;Persist Security Info=True;User ID=thisthesaaccount;Initial Catalog=Northwind;Data Source=."))
{
DataContext db = new DataContext(connection);
connection.Open();
Table<Customer> Customers = db.GetTable<Customer>();
Table<Order> Orders = db.GetTable<Order>();
var custs =
from c in Customers
where c.CompanyName.StartsWith("A")
select new {
c.CustomerID,
c.CompanyName,
NumOrders =
c.Orders.Count
};
this.docPanelCustomers.DataContext = custs;
}
And the result is: once the DLinq select command fires, I get a nice little exception that says, " [System.InvalidOperationException] {"The ConnectionString property has not been initialized."}" :-(
Please drop me a line if you have any thoughts.
On the plus side, I was able to make a really lame "Hello WPF" application...
<Window x:Class="AvalonApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
Text="Hello WPF!"
>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top" Height="100" TextAlignment="Center" FontSize="36">Hello World???</TextBlock>
<StackPanel DockPanel.Dock="Left" VerticalAlignment="Top">
<Button x:Name="buttonSayHello" Click="buttonSayHello_Click" HorizontalAlignment="Left">Hello</Button>
<Button x:Name="buttonSayWPF" Click="buttonSayWPF_Click" Margin="0,10" HorizontalAlignment="Left">WPF</Button>
</StackPanel>
<TextBlock x:Name="textBlockStuff" DockPanel.Dock="Bottom" TextAlignment="Center" Background="#C0C0C0"></TextBlock>
</DockPanel>
</Window>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void buttonSayHello_Click(object sender, RoutedEventArgs e)
{
this.textBlockStuff.TextContent = "Hello";
}
private void buttonSayWPF_Click(object sender, RoutedEventArgs e)
{
textBlockStuff.TextContent = "WPF";
}
}
Also, if you have any thoughts on getting whatever SQL Server 2005 CTP that works with VS2005 Beta 2 up and running, please drop me a line. :-)