i using code in order query through database , inserting values model:
usercontext user = new usercontext(); list<mitarbeiterdatamodel> mitarbeiter = new list<mitarbeiterdatamodel>(); var users = user.users.select(x => new mitarbeiterdatamodel{ id = x.id, vorname = x.vorname, nachname = x.nachname, studio = x.studio }).tolist(); mitarbeiter.addrange(users);
now have list of employees looks example:
------------------------------ | id | name | opportunities | ------------------------------ | 1 | tom | | ------------------------------ | 2 |john | | ------------------------------
my goal fill opportunities column well. problem these values table. have add them later somehow. can tell me how this?
mitarbeiter.where(x => x.id == 1).select(x => new mitarbeiterdatamodel { gelegenheiten = 2 });
'gelegenheiten' means opportunities , present in datamodel mitarbeiterdatamodel
. tried somehow way... no success though:(
like jeff orris said, can join both tables, create viewmodels :
usercontext context = new usercontext(); list<mitarbeiterdatamodel> mitarbeiter = new list<mitarbeiterdatamodel>(); var users = ( user in context.users join opp in context.opportunities on user.oppurtunityid equals opp.oppurtunityid select new mitarbeiterdatamodel { id = user.id, vorname = user.vorname, nachname = user.nachname, studio = user.studio, gelegenheiten = opp.somefield }) .tolist(); mitarbeiter.addrange(users);
of course, don't know content of classes, made fields.
Comments
Post a Comment