I have two Tables in my database one contains User List And Their information. and 2nd contains the data submitted by them. (every user can submit their own data)
but these users are under Any User like this : user15 works under User-Manager user16 works under User-Manager user_xyz works under User-Manager2
├── manager 1/
│ ├── User 15
│ ├── User 16
|── Manager 2/
├── User xyz
├── User Pqr
i want to get all the data from data table of all user who are working under Manager-1 but i am able to do that.
i am doing this to get the list of Users
var t = db.Users.Where(u => u.Under_Control == Manager-1).Select(u => u.UserName).ToList();
it gives me the list of users who are working under Manager-1 Or Manager-2
then i am trying to retrieve data from Data table by using loop eg
foreach(var item in db.userdata) {
create new list of all data...
}
i am failed then i tried this way
var test = (from usr in db.Users from data in db.userdata where user.Under_Control==Undr select data).ToList():
but i am not able to do this.
I Simple Words I have two tables One With Data and Another with Users Each User Works under Their Own Manager
Now what i want the data from Data Table which is submitted by all users who are working under Manager-1 that means if Manager-1 have five user show all data of these five users only, to Manager-1;
thanks Hope you understand my problem.
Here is My Table 1:
Username some-more-info Under_Control
user-15 more info of usr Manager-1
user-16 more info of usr Manager-1
user-xyz more info of usr Manager-2
Table 2:
Submitted_by Date More Fields
user-15 10/01
user-15 10/01
how i can get it now
You need a join - You can try this.
var result = (from u in users
join d in data on u.user equals d.user
where users.under_Control == "Manager-1"
select new{ something = d.something}).ToList();
you may have to update this query.