markrendle / Simple.Data

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

ThenBy should throw NullReferenceException if there is no base command #277

Open hmobius opened 11 years ago

hmobius commented 11 years ago

If I call ThenBy() directly on a table reference without a base command (All, FindAll etc), I'd expect a NullReferenceException to be thrown because there's no command to qualify. However, if I call any of the following

db.Albums.ThenBy();
db.Albums.ThenByArtistId();
db.Albums.ThenBy(db.Albums.ArtistId);
db.Albums.ThenBy(db["Albums"]["ArtistId"]);

I get an InvalidOperationException because there's no OrderBy in the Command. For consistency, I think this should toe the same line as OrderBy and throw NullReferenceException.