'Addressbook.Models.AddressbookRepository' does not implement interface member 'System.IDisposable.Dispose()'
With thise piece of code:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using Addressbook.Repository;
namespace Addressbook.Models
{
public class AddressbookRepository : IAddressbookRepository
{
AddressbookContext context = new AddressbookContext();
public List<Person> GetAddressbook(int id)
{
var query = context.People.Where(x => x.CustomerId == id);
if (query != null && query.Count() != 0)
return query.ToList();
return null;
}
}
public interface IAddressbookRepository : IDisposable
{
List<Person> GetAddressbook(int id);
}
}
I have also other Repository's.. Those I generated with Scaffolding, but now I just tried to make my own AddressBookRepository. I copied it totally the same as the other repositorys, but still get that error. I cant see any difference.
SpaceLama
Member
171 Points
136 Posts
EF: Error: RepositoyX does not implement interface member Dispose()
Jan 03, 2013 07:29 PM|LINK
Hello,
I get the following error:
'Addressbook.Models.AddressbookRepository' does not implement interface member 'System.IDisposable.Dispose()'
With thise piece of code:
using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Linq.Expressions; using System.Web; using Addressbook.Repository; namespace Addressbook.Models { public class AddressbookRepository : IAddressbookRepository { AddressbookContext context = new AddressbookContext(); public List<Person> GetAddressbook(int id) { var query = context.People.Where(x => x.CustomerId == id); if (query != null && query.Count() != 0) return query.ToList(); return null; } } public interface IAddressbookRepository : IDisposable { List<Person> GetAddressbook(int id); } }I have also other Repository's.. Those I generated with Scaffolding, but now I just tried to make my own AddressBookRepository. I copied it totally the same as the other repositorys, but still get that error. I cant see any difference.
Greetings,
Spacelama
SpaceLama
Member
171 Points
136 Posts
Re: EF: Error: RepositoyX does not implement interface member Dispose()
Jan 03, 2013 07:33 PM|LINK
Got the answer:
public void Save() { context.SaveChanges(); } public void Dispose() { context.Dispose(); }