I'm not so experienced with ASP.Net MVC nor with Entitity Framework.
The problem is the following: I do have database table for tax code sets, organizations and table 'DisplayData' which contains information which sets are linked with which organization. Returning all the organizations and all the tax code sets works very well. But now I should be able to build the list of tax codes based on chosen organization.
Relevant code this far looks like this:
IEnumerable<TaxCodes> taxcodelist = null;
IEnumerable<Organizations> orglist = null;
IEnumerable<DisplayData> taxcodeids = null;
model.OrgId = Convert.ToInt64(Request.QueryString["OrgId"]);
if (model.OrgId == 0)
model.OrgId = 1;
taxcodelist = db.TaxCodes.AsNoTracking().Distinct().OrderBy(s => s.Id).ToList();
orglist = db.Organizations.AsNoTracking().Distinct().OrderBy(s => s.org_id).ToList();
taxcodeids = db.DisplayData.Where(s=>s.CompanyId == model.OrgId).ToList();
model.TaxCodeList = new SelectList(taxcodelist, "ID", "Name");
model.OrgList = new SelectList(orglist, "org_id", "org_name");
Well, this works, but really the problem is how to make my TaxCodeList to include only the options that match with the organization?
Thanks for help in advance!