我如何将下面的SQLQuery转换为LINO [英] how can i conver the below SQLQuery into LINO

查看:70
本文介绍了我如何将下面的SQLQuery转换为LINO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT     t_PersonalInformation.personalInformation_Name,             t_PersonalInformation.personalInformation_PresentAddress, 
           t_PersonalInformation.personalInformation_PermanentAddress, t_PersonalInformation.personalInformation_Phone, 
           t_PersonalInformation.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') 

我正在VS2008中使用C#

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
    }

第二个"from"语句是进行外部联接的方法之一.即使没有找到与perInf匹配的记录,该DefaultIfEmpty仍允许它生成ClassName的新记录.一旦您实际在底部的新记录中分配了值,就必须检查是否为空.

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.

这篇关于我如何将下面的SQLQuery转换为LINO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆