I deleted a significant part of the text from this question because I think it needs to be more concise. - Serg
Here is what I am trying to do. The user selects a state, and then the ComboBox loads with Cities in this state, then when the user selects City, the ListBox loads all the projects from this City.
When I run a method that should load projects into a ComboBox, I get this error:
An exception was chosen to target the call. Internal Exception: "{" The specified order is not valid. "}" is valid. "}"
This is the method that throws the exception:
private void LoadProjectsToListBox(long idCity)
{
ProjectRepository projectRepo = new ProjectRepository();
var projects = projectRepo.FindAllProjects().Where(c => c.IDCity == 1).ToList();
}
Linq , . 1, , , . , Linq , . , , , .
SQL, Project City:
create table City
(
ID integer primary key autoincrement,
Name string,
IDState integer references State(ID)
);
create table Project
(
ID integer primary key autoincrement,
Name string,
StartDate text,
IDManager integer references Manager(ID),
IDCity integer references City(ID),
IDDepartment integer references Department(ID),
ContactNumber string,
Description string
);
, , , ( ), , . , , Departments :
private void LoadProjectsToListBox(long idCity)
{
ProjectRepository projectRepo = new ProjectRepository();
DepartmentRepository departmentRepo = new DepartmentRepository();
var projects = projectRepo.FindAllProjects().Where(c => c.IDCity == 1).ToList();
var deps = departmentRepo.FindAllDepartments().Where(c => c.IDParentDepartment == 7).ToList();
lstProjects.Items.Clear();
foreach (var item in deps)
{
lstProjects.Items.Add(item.Name);
}
}
Edit:
FindAllDepartments(), FindAllCities(), FindAllProjects() .
DocumentsDBEntities db = new DocumentsDBEntities();
public IQueryable<Project> FindAllProjects()
{
return db.Projects;
}
public IQueryable<City> FindAllCities()
{
return db.Cities;
}
public IQueryable<Department> FindAllDepartments()
{
return db.Departments;
}
, ; .
3:
! "" Project. "" "", . - , ?