Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc Can';t在我的存储库中使用db.entry_Asp.net Mvc_Linq_Asp.net Mvc 3_Entity Framework_Repository - Fatal编程技术网

Asp.net mvc Can';t在我的存储库中使用db.entry

Asp.net mvc Can';t在我的存储库中使用db.entry,asp.net-mvc,linq,asp.net-mvc-3,entity-framework,repository,Asp.net Mvc,Linq,Asp.net Mvc 3,Entity Framework,Repository,我在我的项目中使用EF模型。我在控制器中使用viewmodel显示数据。但是,我无法访问存储库中的db.entry。为什么我不能访问它 这是我的存储库 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MCT.ViewModels; using System.Data.Entity; using System.Data;

我在我的项目中使用EF模型。我在控制器中使用viewmodel显示数据。但是,我无法访问存储库中的db.entry。为什么我不能访问它

这是我的存储库

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MCT.ViewModels;
using System.Data.Entity;
using System.Data;

namespace MCT.Models
{
    public class AdministrationRep
    {
        Model1Container _db = new Model1Container();

        public void changequstion(Question _question)
        {


        }
在我的存储库中,我想使用

db.entry(model).State = EntityState.Modified;

或者是否有其他方法可以对我的控制器使用编辑?

ObjectContext
API中,您可以按如下方式更改状态

db.ObjectStateManager.ChangeObjectState(model, EntityState.Modified);

ObjectContext
API中,可以按如下方式更改状态

db.ObjectStateManager.ChangeObjectState(model, EntityState.Modified);

您使用的是
DbContext
API还是
ObjectContext
API?为什么存储库依赖于视图模型?存储库只能与域模型一起工作。我使用ObjectContext for APIDarin:我已将其更改为疑问问题您使用的是
DbContext
API还是
ObjectContext
API?为什么存储库依赖于视图模型?存储库应该只与域模型一起工作。我正在使用ObjectContext for APIDarin:我已经将它改为Question