[英]Value in property from WCF service is getting System.ArgumentNullException saying it is null, when it isn't
I have a issue with a view being populated from a WCF service into a partial view. 我将WCF服务中的视图填充到局部视图中时遇到问题。 Everything works just fine and the model contains the data necessary, but somehow it keeps getting this error.
一切正常,并且该模型包含必要的数据,但是以某种方式使其不断出现此错误。 I can clearly see the value for the ProduktDto so it isn't null at all, but still says it is.
我可以清楚地看到ProduktDto的值,因此它根本不是null,但仍然说是。
Have heard that the error could be in the connectionString so I include it here: 听说错误可能在connectionString中,所以我将其包括在这里:
<add name="SpelDatabasContainer" connectionString="metadata=res://*/SpelDatabas.csdl|res://*/SpelDatabas.ssdl|res://*/SpelDatabas.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=SpelAffarenDatabas;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Havent found the answer for this after serious googling. Havent经过严格的谷歌搜索后找到了答案。 Here is the code for the view:
这是该视图的代码:
@model List<SpelAffarWCF.ProduktDto>
<table class="table table-responsive">
<tr>
<th>Id</th>
<th>Namn</th>
<th>Beskrivning</th>
<th>Utgivningsår</th>
<th>MP</th>
<th>SP</th>
<th>Pris</th>
<th>Utgivare</th>
<th>Konsoler</th>
<th>Genres</th>
<th>Aktiv order antal</th>
</tr>
@foreach (var spel in Model)
{
<tr>
<td title="Spelets Id">@spel.Id</td>
<td title="Spelets jävla namn">@spel.Namn</td>
<td title="@spel.Beskrivning">För musen över mig..</td>
<td title="När det släpptes">@spel.Utgivningsår</td>
<td title="Multipläjer">@Html.CheckBox("checkboxMP", spel.Multiplayer)</td>
<td title="Singlpläjer">@Html.CheckBox("checkboxSP", spel.Singleplayer)</td>
<td title="Spelet kostar faktiskt såhär mycket">@spel.Pris</td>
<td title="Id: @spel.Utgivare.Id, Spel: @spel.Utgivare.Produkter.Count()">@Html.ActionLink(spel.Utgivare.Namn, "EditPublisher", new { id = spel.Utgivare.Id })</td>
@if (spel.Konsoler.Count() > 0)
{
<td>
@foreach (var konsol in spel.Konsoler)
{
<p class="cellEntity">@konsol.Namn</p>
}
</td>
}
else
{
<td>Ingen.</td>
}
@if (spel.Genres.Count() > 0)
{
<td>
@foreach (var genres in spel.Genres)
{
<p class="cellEntity">@genres.Namn</p>
}
</td>
}
else
{
<td>Ingen genre.</td>
}
@if (spel.SpelPerOrders.Count() > 0)
{
<td>
@foreach (var spelOrder in spel.SpelPerOrders)
{
<p class="cellEntity">Id: @spelOrder.OrderId, @spelOrder.Antal st</p>
}
</td>
}
else
{
<td>Finns inte i någon order.</td>
}
<td>
<input type="button" value="Lägg till i kundvagn" onclick="AddToCart(@spel.Id)" />
</td>
</tr>
}
</table>
The error indicates it's either the spel.Utgivare.Produkter.Count()
or spel.Konsoler.Count()
call; 该错误表明它是
spel.Utgivare.Produkter.Count()
或spel.Konsoler.Count()
调用; the parameter of the Linq Count
extension method is named source
. Linq
Count
扩展方法的参数名为source
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.