This should be very simple, but its very frustrating.
I have a LinqToSql as below, it works fine in development but when i move the code to production it blows up on .Count
update, resolved the issue, but dont understand why i had to... Please explain if you can, im confused. The code below works fine in development, in order to get it to work in production i had to NOT use deferred typing, so... instead of:
Dim val = From a In开发者_C百科 _configuration Where a.ItemKey = "Val5" Select
I had to use:
Dim val As IEnumerable(Of MyAssembly.Configuration) _
= From a In _configuration Where a.ItemKey = "Val5" Select a
Why in the world would the first way work on my development server but not the production server? They both have 3.5 SP1, etc...
Dim val = From a In _configuration Where a.ItemKey = "Val5" Select a
Dim valExists As Boolean = False
If val.Count > 0 Then
valExists = True
End If
The error i get is: System.MissingMemberException: Public member 'Count' on type 'WhereSelectListIterator(Of Configuration,Configuration)' not found.
This makes absolutely no sense to me. The type of val is IEnumerable so why would i not be able to call .Count on this?
Thanks :-)
try
val.AsEnumerable.Count
?
Just a hunch, try checking if val is returning null for some reason:
If val IsNot Nothing AndAlso val.Count > 0 Then
精彩评论