小编Jel*_*ing的帖子

使用Statement和Entity Framework

只要我不使用注释掉的using语句,以下代码就可以工作.当我用using我得到The operation cannot be completed because the DbContext has been disposed

public IQueryable<DTOs.FormQuestionDTO> GetForm(int id, int page = 0)
{
    // FS stores pages starting with 1
    page = page == 0 ? 1 : page;

    //using (var db = new Models.FormEntities())
    //{
        var db = new Models.FormEntities();

        var questions = from fq in db.FormQuestions
                        join q in db.Questions on fq.QuestionId equals q.QuestionId
                        where (fq.FormId == id) && (fq.PageNumber == page) && fq.Disabled == false …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework

1
推荐指数
1
解决办法
1735
查看次数

标签 统计

c# ×1

entity-framework ×1