c# - How to retrieve parent objects without children -
i have parent class person , child class employee parent class manager
class person { private int _personid; private string _fullname; .... .... } class employee : person { private int _salary; .... .... } class manager : employee { private project _project; .... .... }
now, need employees without managers. tried:
var employees = employee e in db select e;
but noticed have managers inside collection because of inheritance. thought this:
var employees = employee e in db manager m in db e.personid != m.personid select e;
but donэt have managers inside collection have twice same information in collection because of inheritance. need parents without children.
i using db4o object database , not familiar linq.
update:
embeddedobjectcontainer db = db4oembedded.openfile(path_to_database);
i figured out how this, have query twice not best solution.
var employees = employee e in db select e; var managers = manager m in db select m; var result = employees.except(managers);
i not familiar db4o nor db4o linq implementation, standard linq should work:
var employees = db.asqueryable<employee>().where(e => !(e manager));
Comments
Post a Comment