我继承了一些LINQ,我想把它重写为非LINQ C#,这样我就可以解决哪个位失败了。
(我订购了ReSharper,但JetBrains的许可证密钥似乎很慢。)
LINQ是
var accounts = from a in srvContext.CreateQuery<Incident>()
join b in srvContext.CreateQuery<integ_benefitallowances>() on a.integ_BenefitId.Id equals b.integ_benefitallowancesId.Value
where b.integ_BenefitId.Id == _currentIncident.integ_BenefitId.Id
where a.Integ_DependantId.Id == a.Integ_DependantId.Id
where a.integ_ClaimStatus.Value == 0 || a.integ_ClaimStatus.Value == 2
where a.Integ_DateofClaim.Value > timePeriod
select new Incident
{
LogicalName = a.LogicalName
};
错误是
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: There was an error with this process
variable '<>h__TransparentIdentifier2' of type '<>f__AnonymousType0`2[PaycareCRM.Incident,PaycareCRM.integ_benefitallowances]' referenced from scope '', but it is not defined
是否有网站或简单的工具可以将LINQ转换为普通的C#?
答案 0 :(得分:4)
答案 1 :(得分:0)
ReSharper揭示了这个问题 - 一条线是重言式(并且RS下划线强调了它),虽然我不明白为什么这意味着查询失败了。无论如何,固定代码是
var incidents = from a in srvContext.CreateQuery<Incident>()
join b in srvContext.CreateQuery<integ_benefitallowances>() on a.integ_BenefitId.Id equals b.integ_benefitallowancesId.Value
where b.integ_BenefitId.Id == _currentIncident.integ_BenefitId.Id
where a.Integ_DependantId.Id == _currentIncident.Integ_DependantId.Id
where a.integ_ClaimStatus.Value == 0 || a.integ_ClaimStatus.Value == 2
where a.Integ_DateofClaim.Value > timePeriod
select new Incident
{
LogicalName = a.LogicalName
};