Hi,
I have an entity model and I've been looking to write a linq query that returns counts of children and parents for each grandparent.
I need to output 3 columns: Name of Grandparent | Count of Children | Count of Grandchildren
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();
}
}
I've been struggling with SelectMany, Groupby, joins.... I just don't get the result I need for this seemingly simple query. Any input would be greatly appreciated.
Thanks