首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cascading_ddlEntities需要哪个程序集引用?

Cascading_ddlEntities需要哪个程序集引用?
EN

Stack Overflow用户
提问于 2019-12-26 16:45:43
回答 1查看 78关注 0票数 0

我正在遵循一个似乎是最好的解决方案的教程(在搜索了一天之后)。作者没有包含任何名称空间引用。我需要什么才能识别Cascading_ddlEntities,并且不会下划线显示为错误?

我正尝试在asp.net Mvc中为我的web应用程序创建一个级联下拉列表。我对编程很陌生。

代码语言:javascript
复制
public class PartsController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            Cascading_ddlEntities entities = new Cascading_ddlEntities();
            CascadingModel model = new CascadingModel();
            foreach (var country in entities.Area)
            {
                model.Area.Add(new SelectedListItem { Text = Area.AreaName, Value = Area.Id.ToString() })
            };

            return View(model);
        }

教程:https://www.aspsnippets.com/Articles/Implement-Cascading-Dependent-DropDownLists-without-jQuery-in-ASPNet-MVC.aspx

EN

回答 1

Stack Overflow用户

发布于 2019-12-26 17:08:48

因为我有这个项目,所以让我在这里发布完整的类代码

代码语言:javascript
复制
namespace Cascading_DropDownList_Entity_MVC
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;

    public partial class Cascading_ddlEntities : DbContext
    {
        public Cascading_ddlEntities()
            : base("name=Cascading_ddlEntities")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }

        public DbSet<City> Cities { get; set; }
        public DbSet<Country> Countries { get; set; }
        public DbSet<State> States { get; set; }
    }
}

Cascading_ddlEntities是数据库的入口点,它是使用VS生成的。在研究这段代码之前,您需要了解实体框架。EF是本项目中使用的ORM(对象关系映射)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59485938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档