Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top