When using Query Syntax in C# "Enumeration yielded no results". How to retrieve output

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-05-26T05:41:27Z Indexed on 2010/05/26 6:31 UTC
Read the original article Hit count: 267

Filed under:
|
|
|

I have created this query to fetch some result from database. Here is my table structure.

What exaclty is happening.

DtMapGuestDepartment as Table 1

DtDepartment as Table 2

Are being used

    var dept_list=  from map in DtMapGuestDepartment.AsEnumerable()
                    where map.Field<Nullable<long>>("GUEST_ID") == DRowGuestPI.Field<Nullable<long>>("PK_GUEST_ID")
                    join 
                    dept in DtDepartment.AsEnumerable()
                    on map.Field<Nullable<long>>("DEPARTMENT_ID") equals dept.Field<Nullable<long>>("DEPARTMENT_ID")
                    select dept.Field<string>("DEPARTMENT_ID");

I am performing this query on DataTables and expect it to return me a datatable.

Here I want to select distinct department from Table 1 as well which will be my next quest. Please answer to that also if possible.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ