entity-framework - 如何使用实体框架工作 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 之上创建的用于字段验证的模型类。
如何投射这个或者我错过了其他东西......请帮忙
解决方案
推荐阅读
- mysql - 没有用 mysqlimport 导入
- azure - 创建管道后有没有办法编辑 azure-pipelines.yml?
- python - django.db.utils.ProgrammingError: (1064, "你的 SQL 语法有错误;"
- amp-html - 如何禁用 amp-img 默认灯箱功能?
- python - argparse.print_help() ArgumentParser 消息字符串
- javascript - 如何在同一个 Vue.js 项目中使用实时数据库和 Firestore
- node.js - 在 Nodejs 中解析 POST 参数
- ruby-on-rails - 使用带有最新帖子的 Rails 应用程序
- java - 如何获得正确的消息显示?
- python - 如何通过更改 URL 中的一个数字来循环完整的 API 集合