我有一個實體模型,我一直在尋找寫一個linq查詢,返回每個祖父母的子女和父母的計數。linq:祖父母 - 父母 - 子女查詢
我需要輸出3列:祖父母的名字|孩子的數量|孫子
protected void Page_Load(object sender, EventArgs e)
{
using (FamilyModel.TheConn myEntities = new FamilyModel.TheConn())
{
int TheUserID = 13; // will change later
var myOutput = from gparents in myEntities.GrandParents
where gparents.UserID == TheUserID
select gparent.Name, // here's what's missing: the counts
GridView1.DataSource = myOutput;
GridView1.DataBind();
}
}
我一直在用的SelectMany GROUPBY,奮力聯接....我只是沒有得到結果,我需要爲這個看似簡單的查詢次數。 任何輸入將不勝感激。
感謝
我認爲有關架構更多的信息,將有助於 – Murph 2010-10-14 07:56:55