LinqPad“ORA-00933:SQL命令未正确结束”错误

时间:2012-10-06 02:55:05

标签: linqpad

我在LinqPad V4.42.14(AnyCPU)上运行以下linq查询时收到错误:ORA-00933: SQL command not properly ended,数据库是Oracle 11g。

如果我更换

where coof.CoofCode == tod.PatTrnsplntFail.CoofCode && coof.OrgCode == prod.OrgCode

where coof.CoofCode == tod.PatTrnsplntFail.CoofCode

它有效,但我不能删除那个因素。

任何身体都可以帮助我,我将非常感激。

void Main()
{
    var q = (from pat in Pats
            from patr in pat.PatRegisters
            from prod in patr.PatRegisterOrgDets
            from tod in prod.TransplantOrgDets
            select new {
                PatId = pat.PatID,
                FullName = pat.FirstName + ", " + pat.LastName,
                RegisterDate = patr.RegDate.ToString("yyyy-MMM-dd"),
                TransplantDate = tod.Transplant.TransplantDate.ToString("yyyy-MMM-dd"),
                OrganSpec = tod.OrgSpec.Descrip,
                IsTransplantedFailed = tod.PatTrnsplntFail.TodID == 0 ? false: true,
                TransplantedFailReason = from coof in CausesOfOrgFail
                                         where coof.CoofCode == tod.PatTrnsplntFail.CoofCode && coof.OrgCode == prod.OrgCode
                                         select coof.Descrip
            }).Distinct().OrderBy(o => o.PatId);

    q.Dump(true);
}

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法,但实际上我并不认为这是一个好方法,我掉了LinqPad Oracle驱动程序有内部错误引起的问题。 Joeseph如果你能读懂这个,请提出你的建议。因此,请使用以下linq查询:

void Main()
{
    var q1 = (from pat in Pats
            from patr in pat.PatRegisters
            from prod in patr.PatRegisterOrgDets
            from tod in prod.TransplantOrgDets
            where tod.PatTrnsplntFail.TodID == null
            select new {
                PatId = pat.PatID,
                FullName = pat.FirstName + ", " + pat.LastName,
                RegisterDate = patr.RegDate.ToString("yyyy-MMM-dd"),
                TransplantDate = tod.Transplant.TransplantDate.ToString("yyyy-MMM-dd"),
                OrganSpec = tod.OrgSpec.Descrip,
                IsTransplantedFailed = false,
                CausesOfOrgFailReason = ""
            }).Distinct().OrderBy(o => o.PatId);

    var q2 = (from pat in Pats
            from patr in pat.PatRegisters
            from prod in patr.PatRegisterOrgDets
            from tod in prod.TransplantOrgDets
            from coof in CausesOfOrgFail where coof.CoofCode == tod.PatTrnsplntFail.CoofCode && coof.OrgCode == prod.OrgCode
            where tod.PatTrnsplntFail.TodID != null
            select new {
                PatId = pat.PatID,
                FullName = pat.FirstName + ", " + pat.LastName,
                RegisterDate = patr.RegDate.ToString("yyyy-MMM-dd"),
                TransplantDate = tod.Transplant.TransplantDate.ToString("yyyy-MMM-dd"),
                OrganSpec = tod.OrgSpec.Descrip,
                IsTransplantedFailed = true,
                CausesOfOrgFailReason = coof.Descrip
            }).Distinct().OrderBy(o => o.PatId);

    q1.ToList().Union(q2.ToList()).OrderBy(o => o.PatId).Dump(true);
}