0

我收到错误消息:ORA-00933: SQL command not properly ended在 LinqPad V4.42.14(AnyCPU) 上运行以下 linq 查询时,数据库是 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);
}
4

1 回答 1

0

我找到了一种避免该问题的解决方法,但实际上我认为这不是一个好方法,我认为 LinqPad Oracle 驱动程序存在导致该问题的内部错误。乔瑟夫,如果你能读到这个,请给你的建议。因此,请改用以下 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);
}
于 2012-10-08T16:16:58.353 回答