[英]Entity framework 4 not binding properly to datagridview
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... 但是,与其给我刻痕的实体集合,不如给我一个刻痕的实体集合,每个刻有“值”字段的刻痕都会在datagrid视图中给出……
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. 这些表肯定有数据,并且我在以前的项目中一直使用EF,但它的行为并非如此。.所以我不知道为什么。
The edmx is like so : edmx就像这样:
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. 并得到相同的结果。
You're missing a projection: 您缺少投影:
var abc = (from x in _db.HostIPs
where x.Value == host
from s in x.SubIPs
where s.Value == sub
from n in s.Nicks
select n).ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.