I have a UserTbl and a CongregationTbl and I am trying to combine them so that I can retrieve a.FirstName, a.LastName and b.Name.
UserTbl
| C_ID | FirstName | LastName |
+------+-----------+----------+
1 Jim Jones
2 Frank Snow
1 Alice Cruz
2 Sarah Lee
CongregationTbl
| ID | Name |
+------+-----------+
1 Bellham
2 Fortworth
What I want to do return a list and populate that into a view
Created view
| Name | FirstName | LastName |
+--------+-----------+----------+
Bellham Jim Jones
Fortworth Frank Snow
Bellham Alice Cruz
Fortwroth Sarah Lee
This is what I have so far. It returns data, but I cannot get it into my list.
using (Model1 dc = new Model1())
{
var id = (from b in dc.CongregationTbls select b);
var list = from i in dc.UserTbl
where i.AccountConfirmed == false
select new
{ id.FirstOrDefault().Name, i.FirstName, i.LastName };
MergeModel MyModel = new MergeModel();
MyModel.PendingUsers = list.ToList();
return View(myModel);
}