• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

LINQ query to return boolen value

i have 3 tables Group1,Group2,and Group3  
each table contains employee details. i have employee whose ID is say 1 ..so i want to check if this employee is there in any of the above table. Here i use ID to find any record present in any of the table..if i find any record  i have to return True or Fale/ Yes or No any thing...

i need query in LINQ to Entities....

i just need single query which checks the details sing ID...

can you please help on this...

1 Solution
Fernando SotoRetiredCommented:
Hi PradeepDumpala;

Something like this should do what you want.

// The employee ID to search for
int emplyeeID = 1;

ObjectDataContext db = new ObjectDataContext();
var foundEmployee = (from g1 in db.Group1
                     from g2 in db.Group2
                     from g3 in db.Group3
                     where g1.EmployeeID == emplyeeID | 
                           g2.EmployeeID == emplyeeID | 
                           g3.EmployeeID == emplyeeID
                     select new { g1, g2, g3 }).Any(g => g != null);


Open in new window

PradeepDumpalaAuthor Commented:
good i will test it more

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now