It would be useful if you posted your entity objects so we can better understand how you've set it up.
NOTE: I'm using Product here for your Inventory so you can just adjust the naming to meet your actual structure.
public class Department
{
public int Id { get; set; }
public string Name { get;set; }
//If you want to be able to get the products by department you could expose it this way but it could be expensive if there are a lot.
public List<Product> Products { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; } //Product in DB
public string Category { get; set; }
public string Observations { get; set; } //??
public int DepartmentId { get; set; }
public virtual Department Department { get; set; }
}
You'll have to set up the relationships and column names. Personally I use the fluent API but you can add attributes. I recommend you get this working first.
Now to get the products by department you can go either way (depending upon where you put your nav property).
public IEnumerable<Product> GetProductsByDepartment ( int departmentId )
{
//Cleanest to me
return context.Products.Where(x => x.Department.Id == departmentId);
}
//Or go the other way and load the products when the department loads (assuming you are not using lazy loading here...)
public Department GetDepartment ( int departmentId )
{
return context.Departments.IncludeChildren(x => x.Products).FirstOrDefault(x => x.Id == departmentId);
}