0

what can i add a statement where i can get also the one where Applicant context is not contain profile_id or when the profile_id is NULL so i can get all the data .

Heres my code :

var applicantList = (from a in context.Profiles
                                 join app in context.APPLICANTs
                                 on a.PROFILE_ID equals app.Profile_id
                                 select new
                         {
                             a.PROFILE_ID,
                             app.APPLICANT_ID,
                             app.APPLICANT_LastName,
                             app.APPLICANT_FirstName,
                             app.APPLICANT_MiddleName,
                             a.Applicant_LASTNAME,
                             a.Applicant_FIRSTNAME,
                             a.Applicant_MIDDLENAME,
                             a.Applicant_ADDRESS,
                             a.Applicant_CITY,
                             a.Applicant_PHONE,
                             a.Applicant_EMAIL
                         }).AsEnumerable();

        applicantdata = (from s in applicantList
                         orderby s.APPLICANT_ID
                         select new APPLICANT()
    {
        Profile_id = s.PROFILE_ID,
        APPLICANT_ID = s.APPLICANT_ID,
        APPLICANT_LastName = s.Applicant_LASTNAME,
        APPLICANT_FirstName = s.Applicant_FIRSTNAME,
        APPLICANT_MiddleName = s.Applicant_MIDDLENAME,
        APPLICANT_Address = s.Applicant_ADDRESS,
        APPLICANT_City = s.Applicant_CITY,
        APPLICANT_Phone = s.Applicant_PHONE,
        APPLICANT_Email = s.Applicant_EMAIL
    }).AsEnumerable();
Dave Alperovich
  • 32,320
  • 8
  • 79
  • 101
Enrique Gil
  • 754
  • 4
  • 19
  • 50
  • Thanks for editing sir Dave – Enrique Gil May 17 '13 at 02:18
  • 1
    It's hard to understand what you're trying to do. Maybe edit your question further or provide an example of the desired output. – Alaa Masoud May 17 '13 at 05:28
  • sorry sir. .. the output of that is it only shows the data with Profile_id in applicant that is equal to profile_ID of Profiles table – Enrique Gil May 17 '13 at 05:38
  • and i want to show all the data with and without profile_id in applicant table – Enrique Gil May 17 '13 at 05:39
  • 2
    So you want all data from your left table regardless whether a matching row in the right table exists? Then you need a [SQL Left Join](http://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_joins). Check this [SO Question](http://stackoverflow.com/questions/4497086/linq-left-join-and-right-join) on how to make left joins in LINQ. – Alaa Masoud May 17 '13 at 05:44

0 Answers0