Click here to Skip to main content
15,908,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi

i have 3 tables:

1. Doctors: >> DoctorID, DoctorName.

2. AreaDoctors: >> ID, AreaID, DoctorID

3. Maps_Pos: >> ID, DoctorID, IDFromAreaDoctor, Pos_latitude, Pos_longitude

Now, i try to get all doctors from (doctor table) where DoctorID is in (table AreaDoctors) and in same time (not in table Maps_Pos)


C#
var allDoctorsInArea = db.Doctors.Where(i=>i.AreaDoctors.Where(j=>j.AreaID==userInformations.AreaID).Count()>0 && i.Maps_Pos.Count()==0).
.Select(i => new { i.DoctorID, i.DoctorName })
.ToList();

it works fine, but in areadoctor doctor has many record with many area as example:
HTML
id       doctorid        areaid      ect ...

1           1              200 // this in Maps_pos (don't get it)

2           1              205 // this in Maps_pos (dont get it)

3           1              203  // user has this area (203) but i need to get doctorid (1) in this area only because it's don't saved in "Maps_pos"

4           2              300 // this in Maps_pos

ect .......

and Maps_Pos table:
HTML
id       doctorid        IDFromAreaDoctor                                              pos1         pos2    ect ...

1           1                   1    // here 1 is the id of record in areadoctor table  ..            .. 

2           1                   2    // here 2 is the id of record in areadoctor table  ..            .. 

3           2                   4              ..      ..

ect .......

i need to get all doctor that don't has any area record in maps_pos in my example i must data for doctorid = 1 because he have recede are not in maps_pos yet (here ID is = 3)

so please how can i do it throw my above code ?
Posted
Comments
Sergey Alexandrovich Kryukov 7-Sep-15 21:55pm    
What do you mean "how"? You can do it all through learning ADO.NET, SQL and MVC. This is not a good question. How can we figure out what kind of help you may need, except doing your work for you (which is also hardly possible).
What have you tried so far?
—SA

1 solution

Now, i try to get all doctors from (doctor table) where DoctorID is in (table AreaDoctors) and in same time (not in table Maps_Pos)

Select * from Doctors
where doctorid IN (select doctorid from Areadoctors
and doctorid NOT IN (select doctorid from Maps_pos

something like that
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900