LINQ Help

  • Thread starter Thread starter Satish
  • Start date Start date
S

Satish

Hi
I an newbie to LINQ.

I have a dataset with one table employee which has a self referencing
foreign key manger id. I want to write a query to get all the employees
under a particular manager. I tried the following query

var results = from e in emp.employee
where e.employeeRowParent.name == "Doe"
select e;
but when I run this I get a null ref exception in the where. How should
I rewrite this query ?
 
Satish said:
I an newbie to LINQ.

I have a dataset with one table employee which has a self referencing
foreign key manger id. I want to write a query to get all the employees
under a particular manager. I tried the following query

var results = from e in emp.employee
where e.employeeRowParent.name == "Doe"
select e;
but when I run this I get a null ref exception in the where. How should
I rewrite this query ?

Well, it looks like the employeeRowParent is null - how about:

var results = from e in emp.employee
where e.employeeRowParent != null &&
e.employeeRowParent.name == "Doe"
select e;
 
Thanks Jon that works.
Jon said:
Well, it looks like the employeeRowParent is null - how about:

var results = from e in emp.employee
where e.employeeRowParent != null &&
e.employeeRowParent.name == "Doe"
select e;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top