实体框架 4 未正确绑定到 datagridview
我运行以下代码:
private void btnMatchFull_Click(object sender, EventArgs e)
{
Match m = Regex.Match(txtIP.Text, "(?<HostIP>[A-Z0-9.]{13}).(?<SubIP>[A-Z0-9.]{13})");
string host = m.Groups["HostIP"].Value;
string sub = m.Groups["SubIP"].Value;
var abc = (from x in _db.HostIPs
where x.Value == host
from s in x.SubIPs
where s.Value == sub
select s.Nicks).ToList();
dgvNicks.DataSource = abc;
}
但是,它没有给我缺口的实体集合,而是在数据网格视图中给出了每个缺口的实体集合,每个缺口都带有“值”字段...
这些表肯定有数据,我在之前的项目中使用过 EF,效果很好,但它的行为却不是这样的..所以我不知道为什么。
edmx 就像这样:
编辑:
我尝试了
var abc = (from x in _db.HostIPs
where x.Value == host
from s in x.SubIPs
where s.Value == sub
select s.Nicks).ToList();
并得到了相同的结果。
Im running the following code :
private void btnMatchFull_Click(object sender, EventArgs e)
{
Match m = Regex.Match(txtIP.Text, "(?<HostIP>[A-Z0-9.]{13}).(?<SubIP>[A-Z0-9.]{13})");
string host = m.Groups["HostIP"].Value;
string sub = m.Groups["SubIP"].Value;
var abc = (from x in _db.HostIPs
where x.Value == host
from s in x.SubIPs
where s.Value == sub
select s.Nicks).ToList();
dgvNicks.DataSource = abc;
}
But instead of giving me the entity collection of nicks, each one with field of "Value" it gives this inside the datagrid view...
The tables definately have the data and I have used EF in a previous project fine and it did not behave like this.. so I have no idea why.
The edmx is like so :
EDIT:
I tried
var abc = (from x in _db.HostIPs
where x.Value == host
from s in x.SubIPs
where s.Value == sub
select s.Nicks).ToList();
And got the same result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你缺少一个投影:
You're missing a projection: