I try to get an entity updated using wpf+entity framework 5. I have a datagrid which looks like this:
<DataGrid x:Name="activityDataGrid"
AutoGenerateColumns="False"
EnableRowVirtualization="True"
ItemsSource="{Binding Source={StaticResource activityViewSource}}"
RowDetailsVisibilityMode="VisibleWhenSelected"
IsReadOnly="false"
SelectedItem="ID"
SelectionChanged="activityDataGrid_SelectionChanged"
CellEditEnding="activityDataGrid_CellEditEnding"
RowEditEnding="activityDataGrid_RowEditEnding">
<DataGrid.Columns>
<DataGridTextColumn x:Name="col_activityDate" Header="Datum" Binding="{Binding DATE_, StringFormat=\{0:d\}}" Width="Auto"/>
<DataGridTextColumn x:Name="col_activityDescription" Binding="{Binding DESCRIPTION}" Header="Tätigkeit" Width="Auto" />
<DataGridTextColumn x:Name="col_activityDuration" Binding="{Binding DURATION}" Header="Dauer" Width="Auto" />
<!--<DataGridTextColumn x:Name="iDColumn" Binding="{Binding ID}" Header="ID"/>-->
<DataGridTextColumn x:Name="col_activityIsBillable" Binding="{Binding IS_BILLABLE}" Header="verrechenbar" Width="Auto" />
<DataGridTextColumn x:Name="col_activityIsDrive" Binding="{Binding IS_DRIVE}" Header="Anfahrt" Width="Auto" />
<DataGridTextColumn x:Name="col_activity_task" Binding="{Binding TASK_ID}" Header="Aufgabe" Width="Auto" />
<DataGridTextColumn x:Name="col_activityWorker" Binding="{Binding WORKER.USERNAME}" Header="User" Width="*"/>
</DataGrid.Columns>
</DataGrid>
c#:
private void activityDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
//how to update the object??
db.SaveChanges();
}
Thanks in advance!