选择新的fire new查询时,将LINQ转换为SQL

时间:2016-09-13 08:04:16

标签: c# sql-server linq

这里我的LINQ代码在传递名称@ string和CaseConfigType中是一个枚举值,我想在SQL中转换这个查询。请帮帮我。

var selectedCase = (from caseList in ezrCaseConfig.ecc_cases
                    where
                    caseConfigType == CaseConfigType.CaseName ?
                    (name != string.Empty ? caseList.name == name : caseList.name != null) :

                    caseConfigType == CaseConfigType.ClientMatter ?
                    (name != string.Empty ? caseList.ClientMatter == name : caseList.name != null) :

                    (name != string.Empty ? caseList.ClientMatter == name | caseList.ClientMatter == null : caseList.name != null)

                    join dbServer in ezrCaseConfig.ecc_servers on caseList.server_id equals dbServer.server_id
                    join caseVersion in ezrCaseConfig.ecc_versions on caseList.version_id equals caseVersion.version_id
                    select new
                    {
                        caseList,
                        dbServer,
                        caseVersion,
                        baseDir = (from baseDirList in ezrCaseConfig.ecc_case_basedirectories
                                   where baseDirList.case_id == caseList.case_id && baseDirList.dir_type.Equals("R") &&
                                       (baseDirList.status.Equals('A') || baseDirList.status.Equals('C'))
                                   select baseDirList.physical_location).ToList(),
                        workFolderDir = (from baseDirList in ezrCaseConfig.ecc_case_basedirectories
                                         where baseDirList.case_id == caseList.case_id && baseDirList.dir_type.Equals("W") &&
                                             (baseDirList.status.Equals('A') || baseDirList.status.Equals('C'))
                                         select baseDirList.physical_location).ToList()
                    });

0 个答案:

没有答案