不包含定义 [英] Does not contain a definition

查看:155
本文介绍了不包含定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个空的ASP.net MVC 3应用程序,我使用数据库优先"方法创建了它.

在该数据库中,我有两个带有某些字段的表,它们的名称分别是User和Organization.

现在在模型中,

我创建了三个类,即Login,User,Organization,对于Login类,我在数据库中没有任何表
我用与数据库表中相同的名称声明了变量User和Organization类...

现在,我想在Login类中使用用户和组织变量,并为此将它们声明为Vitual.

后来我添加了控制器和dropdownlist视图包,并查看并运行了它,并提示错误消息如下..

``System.Collections.Generic.IEnumerable< emvc_css.models.modelclasses.user_details_class>''不包含``UName''的定义,也没有扩展方法``UName''接受类型为``System''的第一个参数.可以找到Collections.Generic.IEnumerable< emvc_css.models.modelclasses.user_details_class>''(您是否缺少using指令或程序集引用?)


解决这个问题的任何想法

Hi all,

I have a Empty ASP.net MVC 3 app and i created it by using "Database First" approach.

In that database, i have two tables with some fields and their names are User and Organization.

Now in Model,

i created three classes namely Login, User, Organization, and for Login class i did not have any table in database
and i declared the variables User and Organization classes with same names as that are in database tables...

Now i want to use the user and organization variables into Login class and for that i declared them as Vitual.

later i added the controller and dropdownlist view bag and view and runned it and it is prompting the error message as follows..

''System.Collections.Generic.IEnumerable<emvc_css.models.modelclasses.user_details_class>'' does not contain a definition for ''UName'' and no extension method ''UName'' accepting a first argument of type ''System.Collections.Generic.IEnumerable<emvc_css.models.modelclasses.user_details_class>'' could be found (are you missing a using directive or an assembly reference?)


any idea regading this to solve the problem

推荐答案

在这种情况下通常会提示此错误-

如果要从控制器中的方法传递IEnumerable值,则无法在其相应的视图中捕获它,例如-

@model IEnumerable<您的类型=">
它应该在视图的顶部.
This error usually prompt in this situation-

If you were passing the IEnumerable value from a method in controller then not catching it in its respective view like-

@model IEnumerable<your type="">
it should be on the top of your view.


这篇关于不包含定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆