I have three classes defined as follows:
public class MaterialByOperator
{
public int IdOperator{ get; set; }
public int IdMaterial { get; set;}
}
public class Material
{
public int Id { get; set; }
public string Name { get; set; }
}
public class AssignedOperator
{
public int idOperation { get; set; }
public int idOperator { get; set; }
}
IdMaterialin MaterialByOperatoris "ForeignKey" for Material. Attitude One to Many.
IdOperatorin MaterialByOperatoris the "ForeignKey" for AssignedOperatorin One to One.
Then I define this 3 ObservableCollection:
public ObservableCollection<Material> Materials;
public ObservableCollection<MaterialByOperator> MaterialsXOperator;
public ObservableCollection<AssignedOperator> AssignedOperators;
I want to get the names of operators who do not have any materials. Now I will do this:
var mate = MaterialsXOperator.GroupBy(x => x.idOperator);
var opeasigmate = AssignedOperators.GroupJoin(mate, oper => oper.idOperator,
grupo => grupo.Key, (oper, grupo) => new { oper, grupo });
var operWithoutmate = opeasigmate.Where(x => x.grupo.Count() == 0);
What do I want to know, since my LINQ knowledge is not very wide (believe it or not, I have forbidden this from my work for many years) is there any simplest way to archive what I want? As I said, my solution works, but I would like to see other points of view that, I hope, will be studied, by the way.