首页 新闻 会员 周边

关于ADO.NET entity删除问题

0
悬赏园豆:5 [已解决问题] 解决于 2009-04-17 10:55

无法删除此对象,因为未在 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请问怎么解决这个不能删除的原因啊

余韬的主页 余韬 | 初学一级 | 园豆:190
提问于:2009-04-14 13:53
< >
分享
最佳答案
1

attach the object to the context first

imddb | 菜鸟二级 |园豆:250 | 2009-04-14 14:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册