2013-01-04 16 views
0

虽然呼叫Web服务方法,我得到的错误如下:错误在里面Linq查询web服务我想

GenericException
时发生意外错误。 值不能为空。
参数名称:源 在System.Linq.Enumerable.Where [TSource](IEnumerable的1 source, Func 2谓词)
在QuotingGate.CalcsLV.Casco.Standard.Ergo.Calculate(VehicleQuotingParameters参数,CascoQuote &引号)在C:\项目\ XXX \ Web服务\ QuotingGate \ CalcsLV \卡斯科\标准\ Ergo.cs:线152
在QuotingGate.CalcsBase.CalculatorBase`4.Quote(在参数)在C:\项目\ XXX \ Web服务\ QuotingGate \ CalcsBase \ Base.cs:线138

Ergo.cs line 152有这样的LINQ查询:

var territory = from c in prices.premiums where c.tariffParam3 == "LV" select c; 

一派,发现很多情况下,有Single代替SingleOrDefault ..但在我的情况下,其LINQ和继电器不要紧,有没有什么结果,或者没有,对不对?


价格都在这里设置:

... 
     policyDataKASKORetParam1 prices = null; 
    prices = ws.GetCascoQuotesUnregistered(quote, 
          parameters.Vehicle.VIN, 
          parameters.Vehicle.Make, 
          parameters.Vehicle.Model, 
          parameters.Vehicle.ManufactureDate.Value.Year, 
          parameters.Vehicle.Value.Value, 
          parameters.Vehicle.EngineCapacity ?? 0, 
          parameters.Insurance.StartDate.Value, 
          parameters.Insurance.Currency.ToString(), irJaunakLiet, parameters.Client.Code, parameters.Vehicle.OwnerCode, irDefinetieServisi); 
     enter code here 
    ... 

和方法调用:

public policyDataKASKORetParam1 GetCascoQuotesUnregistered(CascoQuote quote, string vin, string make, string model, int year, int vehicleValue, int engine, DateTime policyStartDate, string currency, bool irJaunakLiet, string clientCode, string ownerCode, bool irDefinetieServisi) 
     { 
      policyDataKASKORetParam1 prices; 
      string personCode = string.IsNullOrWhiteSpace(Config.FixedOwnerCode) ? clientCode : Config.FixedOwnerCode; 

      DateTime start = policyStartDate; 
      DateTime issue = DateTime.Today; 
      prices = WS.getOfferDataKASKO(SessionKey, 
       personCode, // Holder Code 
       null, 
       null, 
       vin, 
       make, 
       model, // Model 
       year, // Year 
       engine, // Engine 
       string.Empty, // Usage 
       ownerCode, // Person Code 
       true, 
       false, 
       false, 
       false, 
       false, 
       false, 
       true, 
       false, 
       irJaunakLiet, 
       false, 
       irDefinetieServisi, 
       false, // TODO: All risks 
       (double)vehicleValue, 
       currency, 
       issue, 
       start, 
       null, 
       0d, 
      null, 
       null); 
      if (prices.status != 0) 
       quote.ErrorList.Add(new QuoteBase.Error(Errors.InsurerError, string.Format("Error message: {0}", prices.statusText))); 
      return prices; 
     } 

基本上最后的方法调用了Web服务方法..所以都在一起,我可以假设Web服务不会返回任何东西,或者可能存在其他可能性,为什么它结束为空。 (不知道如何调试它,它在远程服务器上运行..试图WCF跟踪,但没有任何结果..)

问题是在另一个国家和商界人士告诉我,所有的Web服务应该工作所以他们说我的price.premiums不是零..但没有调试,不能真正与他们争论。我应该让客户端运行Web服务并在本地机器上运行它吗?或者有没有另外一种可能性来查看运行实例的值?

此外,他们说,Web服务还没有改变 - 我也知道100%是我的代码没有被改变,以及所有工作得很好像10天前..

(PS我少年谁的导师已经离开..〜只有4个月经验)

+0

你肯定prices.premiums没有空? –

回答

2

从MSDN,这里的Where extension method的签名:

public static IEnumerable<TSource> Where<TSource>(
    this IEnumerable<TSource> source, 
    Func<TSource, bool> predicate 
) 

正如你所看到的,source是对应于收集和您的错误参数消息指示'参数名字:来源'所以我的猜测是,prices.premiums为空。