1
votes
    var updateItem = (from item in ctx.LI_MyList
              where
              item.Id == 1
              select item).First();

I got the following exception when executing the query:

System.ArgumentException: Value does not fall within the expected range.

However InsertOnSubmit () is working, I tried the query with LINQPad but I got the same exception, here is LINQPad StackTrace:

The same list is responding normaly to CAML queries,

The same query is running normaly on other lists in the same site,

I Googled the exception but it seems to be caused by various reason.

Excuse my English and feel free to edit the question.

1

1 Answers

-1
votes

Is there an item with ID equal to 1?

If not your query will not return results and the .First() function will fail.

If possible try the FirstOrDefault() function but you will need an extra test to check if your 'updateitem' variable is not null.