如何从数据库中永久删除值 [英] How to permanently delete values from the database

查看:94
本文介绍了如何从数据库中永久删除值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从javascript调用的方法,该方法假定要永久删除记录,但如果该方法具有DataContext db = new DataContext();,则不会进入该方法,它会给出错误Internal Server Error

I have a method that i call from a javascript, the method suppose to delete the records permanently but it does not go in to the method if the method has DataContext db = new DataContext();, it gives the error Internal Server Error

public void PermanantlyDeleteComment(GetCommentInput input)
{
    DataContext db = new DataContext();
    //Follow by the code to delete the comment
}

如果我注释掉DataContext db = new DataContext();,则断点会进入.

If i comment out DataContext db = new DataContext(); the breakpoint does go in.

我认为问题出在数据上下文上,但我确实知道在哪里

I think the problem is with the datacontext but i do know know where

这是数据上下文

public DataContext() : base("name=Default")
{
    this.Configuration.AutoDetectChangesEnabled = true;
    this.Configuration.LazyLoadingEnabled = true;
}

我使用DataContext是因为abp样板不想永久删除,只能进行软删除,如果您有一种方法可以用样板硬删除,请告诉我.

I'm using DataContext because abp boilerplate does not want to permanently delete, only soft delete, if you have a way that i can hard delete with boilerplate please let me know.

推荐答案

我发现DataContext是正确的,只是我在数据库库(具有DataContext.cs)和我的数据库库中有不同的EntityFramework版本网络图书馆

I found out that the DataContext was correct, is just i had different EntityFramework version on my Database Library (which has DataContext.cs) and my Web Library

这篇关于如何从数据库中永久删除值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆