XAML:
<Window x:Class="DataGridSQLExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="Window_Loaded"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid Name="DataGridTest"></DataGrid>
</Grid>
</Window>
readonly NorthwindEntities dataEntities = new NorthwindEntities();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ObjectQuery<Customers> customers = dataEntities.Customers;
var query =
from customer in customers
where customer.City == "London"
orderby customer.CustomerID
select new { customer.CustomerID, customer.CompanyName, customer.ContactName,
customer.ContactTitle };
DataGridTest.ItemsSource = query.ToList();
}
<Window x:Class="DataGridSQLExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="Window_Loaded"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid Name="DataGridTest"></DataGrid>
</Grid>
</Window>
readonly NorthwindEntities dataEntities = new NorthwindEntities();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ObjectQuery<Customers> customers = dataEntities.Customers;
var query =
from customer in customers
where customer.City == "London"
orderby customer.CustomerID
select new { customer.CustomerID, customer.CompanyName, customer.ContactName,
customer.ContactTitle };
DataGridTest.ItemsSource = query.ToList();
}