I want to fetch only one row with C# LINQ:
collection.AsQueryable().Take( 1).OrderByDescending(x => x.Id).Single();
I am getting the following error:
Sequence contains more than one element
Isn't this is what
Take(1)
is for?
Go ahead and change this to First() instead of Single(). When we see a Single, we set the limit to 2 to match the semantics of what Single() means. I haven't decided yet if I consider this a bug or not, but I can certainly see it would seem like it would be and am leaning that way. Feel free to file a bug report at https://jira.mongodb.org/ secure/Dashboard.jspa under the CSHARP project.
댓글 없음:
댓글 쓰기