Skip to main content
 首页 » 编程设计

c#之解码 LINQ 的服务

2024年02月13日15zhujiabin

我继承了一些 LINQ,我想将其重写为非 LINQ C#,这样我就可以找出失败的部分。

(我已经订购了 ReSharper,但 JetBrains 的许可证 key 似乎很慢。)

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#?

请您参考如下方法: