无法删除此对象,因为未在 ObjectStateManager 中找到它。
代码如下
var af =ListViews.SelectedItem as Customer ;
if (af != null)
{
context.DeleteObject(af);
context.SaveChanges();
}
无法删除此对象,因为未在 ObjectStateManager 中找到它。
<ListView x:Name="ListViews" Grid.Row="1" Width="Auto" HorizontalAlignment="Stretch" Height="Auto" VerticalAlignment="Stretch">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=name}" />
<GridViewColumn Header="Pass" DisplayMemberBinding="{Binding Path=pass}" />
</GridView>
</ListView.View>
</ListView>
z请问怎么解决这个不能删除的原因啊
attach the object to the context first