似乎无法对实体进行智能感知(实体数据框架)
我的代码如下:
var contactGroups = context.ContactGroups.Where(cg => cg.ContactID == contact.ID);
var MyContactGroups = from cg in context.ContactGroups
where cg.Contact == contact.ID
select new {
Title = cg.Title,
GroupName = cg.GroupName
};
contactgroups 和 MyContactGroups 的结果不允许我访问 ContactGroups 的任何记录。
即当我使用 MyContactGroups 时,我无法访问任何列,例如 组名称或标题。例如,我无法使用 MyContactGroups.Title
我已在此处发布了我的问题的视频: http://screencast.com/t/i0ydKQSou
请问我做错了什么吗? 谢谢!
My code is as follows:
var contactGroups = context.ContactGroups.Where(cg => cg.ContactID == contact.ID);
var MyContactGroups = from cg in context.ContactGroups
where cg.Contact == contact.ID
select new {
Title = cg.Title,
GroupName = cg.GroupName
};
The result of contactgroups and MyContactGroups doesn't allow me to access any of the records of ContactGroups..
i.e. When I use MyContactGroups I cannot access any of the columns such as GroupName or Title. For example, I can't use MyContactGroups.Title
I have posted the video of my issue here:
http://screencast.com/t/i0ydKQSou
Any ideas what I am doing wrong please?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MyContactGroups
将是IEnumerable
。您需要从中获取单个项目才能访问 ContactGroup 的属性。MyContactGroups
is going to be anIEnumerable<ContactGroup>
. You'll need to get an individual item off of it to access the properties of a ContactGroup.