实体框架 asp.net MVC3 .NET 4
我有一点小问题。使用我的 asp.net mvc3 应用程序。 当我尝试编译我的应用程序时,我收到此错误
错误 2 'Blog.Domain.Concrete.EFEntryRepository' 未实现接口成员 'Blog.Domain.Abstract.IEntryRepository.SaveEntry(Blog.Domain.Entities.Entry)' D:\dokumenty\Visual Studio 2010\Projects\MVC3\Blog\Blog.Domain\Concrete\EFEntryRepository.cs 10 19 Blog.Domain
这是我的界面。
namespace Blog.Domain.Abstract { public interface IEntryRepository { IQueryable<Entry> Entries { get; } void SaveEntry(Entry entry); void DeleteEntry(Entry entry); } }
这是我的实现。
public class EFEntryRepository : IEntryRepository { private EFDbContext context = new EFDbContext(); public IQueryable<Entry> Entries { get { return context.Entries; } } public void SaveEntry(Entry entry) { if (entry.EntryID == 0) context.Entries.Add(entry); context.SaveChanges(); } public void DeleteEntry(Entry entry) { context.Entries.Remove(entry); context.SaveChanges(); } }
这是我的项目的链接。 http://sigma.ug.edu.pl/~kkubacki/Blog.zip //新 现在我正在编译。
我做错了什么?
我有关于该错误的新信息。现在解决方案正在编译,但应用程序因错误信息而崩溃 “{”未映射类型“Blog.Domain.Concrete.Entry”。检查是否未使用 Ignore 方法或 NotMappedAttribute 数据注释显式排除该类型。验证该类型是否被定义为类,不是原始类型、嵌套类型或泛型类型,并且不是从 EntityObject 继承。"} " Visual studio 显示 EFEntryRepository 类中的错误。
我不知道该怎么办请帮忙。
好的问题已解决。
I Have a little snag. With my asp.net mvc3 application.
When I trying to compile my app I obtain this Error
Error 2 'Blog.Domain.Concrete.EFEntryRepository' does not implement interface member 'Blog.Domain.Abstract.IEntryRepository.SaveEntry(Blog.Domain.Entities.Entry)' D:\dokumenty\Visual Studio 2010\Projects\MVC3\Blog\Blog.Domain\Concrete\EFEntryRepository.cs 10 19 Blog.Domain
This is my Interface.
namespace Blog.Domain.Abstract { public interface IEntryRepository { IQueryable<Entry> Entries { get; } void SaveEntry(Entry entry); void DeleteEntry(Entry entry); } }
And this is my implementation of it.
public class EFEntryRepository : IEntryRepository { private EFDbContext context = new EFDbContext(); public IQueryable<Entry> Entries { get { return context.Entries; } } public void SaveEntry(Entry entry) { if (entry.EntryID == 0) context.Entries.Add(entry); context.SaveChanges(); } public void DeleteEntry(Entry entry) { context.Entries.Remove(entry); context.SaveChanges(); } }
This is link to my project. http://sigma.ug.edu.pl/~kkubacki/Blog.zip //NEW
Now I is compiling.What I Do Wrong ?
I have new Information about the bug. Now the solution is compiling but the application crashes with the bug information
"{"The type 'Blog.Domain.Concrete.Entry' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject."} " Visual studio shows bug in the EFEntryRepository class.I don't know what to do please help.
OK Problem IS Solved.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在不同的命名空间中有两个不同的
Entry
类。Blog.Domain.Entities.Entry
Blog.Domain.Concrete.Entry
接口引用一个,实现引用另一个。
You have two different
Entry
classes in different namespaces.Blog.Domain.Entities.Entry
Blog.Domain.Concrete.Entry
The interface is referring to one and the implementation is referring to the other.