【发布时间】:2016-09-11 10:17:41
【问题描述】:
我试图实现一个通用存储库,我现在有这个:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.Entity.Core.Objects;
using Web_API.Models;
namespace Web_API.DAL
{
class GenericRepository<T> : IRepository<T> where T : class
{
private ApplicationDbContext entities = null;
IObjectSet<T> _objectSet;
public GenericRepository(ApplicationDbContext _entities)
{
entities = _entities;
_objectSet = entities.CreateObjectSet<T>();
}
...
我在调用这个方法时遇到了问题:
entities.CreateObjectSet<T>();
应该没问题,但是我收到此错误:
我已经将 System.Data.Entity 添加到我的项目中,此时我不知道还能做什么。我正在关注本教程http://www.codeproject.com/Articles/770156/Understanding-Repository-and-Unit-of-Work-Pattern。有谁知道如何解决这个问题?
【问题讨论】:
标签: c# asp.net entity-framework asp.net-web-api repository-pattern