I am using this code in order to query through the database and inserting the values into a 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 I have a list of employees which looks like this for example:
------------------------------
| Id | Name | Opportunities |
------------------------------
| 1 | Tom | |
------------------------------
| 2 |John | |
------------------------------
My goal is to fill the Opportunities column as well. The problem is that these values are from another table. So I have to add them later somehow. Can someone tell me how to do this?
mitarbeiter.Where(x => x.Id == 1).Select(x => new MitarbeiterDataModel { Gelegenheiten = 2 });
'Gelegenheiten' means opportunities and is present in my dataModel which is MitarbeiterDataModel
.
I tried it somehow this way... No success though:(