There are two tables:
Account (id)
and BranchId(Id,Name,AccountId)
and I have this code in pageload
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
using (var db = new SitesDataContext())
{
BranchGrid.DataSource = db.Branches.Where(b=>b.AccountId == loggedInUser.AccountId).ToList();
BranchGrid.DataBind();
}
}
}
I understand about Linq and lazy loading and that is why I used ToList()
But I was still getting error.
Now if I remove the association b/w Branch and Account, the above code works fine. However it throws exception with the association.
How can this be resolved while still keeping the association?
Thanks