0

Using SubSonic 2.2, I have this query:

string q = @"SELECT Media.Id, Media.Title FROM Media WHERE Media.UserId = 7"
DAL.MediumCollection matches = new InlineQuery().ExecuteAsCollection<DAL.MediumCollection>(q).Load();

Looping through "matches" results in every single entry in the "Media" table.

However, when I do this:

IDataReader reader = new InlineQuery().ExecuteReader(q);

It returns the correct rows. Why is ExecuteAsCollection returning something completely different from ExecuteReader? Has anyone else experience this strange behavior?

Arthur Chaparyan
  • 2,015
  • 6
  • 29
  • 35

2 Answers2

2

I think it's because you're calling .Load(). That's overwriting your original query.

Dave Neeley
  • 3,526
  • 1
  • 24
  • 42
0

ExecuteAsCollection() should do it.

When you call the Load() method it's just like doing new DAL.MediumCollection().Load() that returns all the data in the table.

Yitzchok
  • 691
  • 3
  • 18