首页 > 解决方案 > 如何使用实体框架工作 mvc 实现存储库模式

问题描述

我正在尝试在 mvc 中实现存储库模式。但我被困住了。我想返回相关数据。我有两个类,tbl_Account(包含用户)和 tbl_Country(包含国家)。

    public class AccountRepository : IAccount
    {
    public IEnumerable<Account> GetCountry()
    {

       var Account = this.storeDB.tbl_UserAccount.Include(s => s.tbl_Country).ToList();
        
       return Account; // it gives error here, saying explicit cast required
    }
    }

Account 是我在 tbl_Account 之上创建的用于字段验证的模型类。

如何投射这个或者我错过了其他东西......请帮忙

标签: entity-frameworkmodel-view-controllerrepository-pattern

解决方案


推荐阅读