markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 303 forks source link

Calling First() or FirstOrDefault() within a Select function should throw InvalidOperationException #292

Closed hmobius closed 11 years ago

hmobius commented 11 years ago

If you call either of

var db = Database.Open().Albums.Select(db.Albums.First());
var db = Database.Open().Albums.Select(db.Albums.FirstOrDefault());

You get a NullReferenceException thrown back. If you call

var db = Database.Open().Albums.All().Select(db.Albums.First());
var db = Database.Open().Albums.All().Select(db.Albums.FirstOrDefault());

You get an InvalidOperationException thrown back. Suggest that both calls should throw an InvalidOperationException.

hmobius commented 11 years ago

Applies also to Single() and SingleOrDefault()

markrendle commented 11 years ago

Fixed.