开发者

how can i conver the below SQLQuery into LINO

SELECT     t_PersonalInformation.personalInformation_Name,             t_PersonalInformation.personalInformation_PresentAddress, 
           t_PersonalInformation.personalInformation_PermanentAddress, t_PersonalInformation.personalInformation_Phone, 
           t_Pers开发者_StackOverflowonalInformation.personalInformation_Email,

           t_Applicant.applicant_TotalExperience,

           t_Experience.experience_CompanyName, CAST( t_Experience.experience_EndingYear AS INT) - CAST( t_Experience.experience_JoiningYear AS INT) AS yearOfExperience ,
           t_Experience.experience_Responsibilities,

           t_Training.training_TitleDetails,   t_Training.training_Institute,
           t_Training.training_Year,           t_Training.training_Duration


FROM         t_Applicant LEFT OUTER JOIN
             t_PersonalInformation ON  t_Applicant.applicant_user_ID = t_PersonalInformation.personalInformation_applicant_ID

             LEFT OUTER JOIN   
             t_Experience          ON  t_Applicant.applicant_user_ID = t_Experience.experience_applicant_ID

             LEFT OUTER JOIN
             t_Training            ON  t_Applicant.applicant_user_ID = t_Training.training_applicant_ID



WHERE     (t_Applicant.applicant_user_ID = 'hasib789') 

i am using in C# with VS2008


I don't really have the time to go through all of that, but I can give you an idea of how it's done.

var query = from var applicant in t_Applicant
    from perInf in t_PersonalInformation.Where(per => applicant.applicant_user_ID = per.personalInformation_applicant_ID).DefaultIfEmpty()
    where applicant.applicant_user_ID == "hasib789"
    select new ClassName{
        Name = perInf!=null ? perInf.personalInformation_Name : <default value>,
        PresentAddress = perInf!=null ? perInf.personalInformation_PresentAddress: <default value>,
        ...
        etc
    }

That second 'from' statement is one of the ways to do an outer join. That DefaultIfEmpty allows it to generate a new record of ClassName even if no matching record for perInf is found. Once you actually go to assign the values in your new record at the bottom, you have to check for null.

Using that template you should be able to get the rest of the query built.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜