markrendle / Simple.Data

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

Empty List Throws Exception in SQL Server #362

Open burkhartt opened 9 years ago

burkhartt commented 9 years ago

One issue that we've run into a lot (we know about it so we are more defensive against it) is that if you pass an empty list into a where clause, it blows up.

For example:

var ids = new List(); db.People.All().Where(db.People.Id == ids);

That line will blow up. I know that I can do db.People.FindAllById(ids) but I just made a simple example to show how to reproduce the error. In fact, the db.People.FindAllById(ids) may also blow up, but I'm not certain off hand.

If this could be fixed to return an empty list of the desired type, that would be amazing!

So this is how I would expect it to behave:

var ids = new List(); List dbPeople = db.People.All().Where(db.People.Id == ids).ToList(); dbPeople.Count().ShouldEqual(0);

praveensastry commented 9 years ago

Hi, I am new to Simple.Data and I Just loved it. I wanna contribute to this Project and I think I could start my work from this bug. Could you please throw me some pointers that are of help??

praveensastry commented 9 years ago

hey @burkhartt btw, FindAllById is also blowing up!