Search code examples
subsonicloadsubsonic3

Subsonic load objects by a list of ids


Is it possible to load objects by a list of ids using subsonic ActiveRecord? My code looks like:

IList<Video> videos = Video.Find(v => videoIds.Contains(v.ID));

I get an exception: The method 'Contains' is not supported

Do I do something wrong ... or I hit one of subsonic's limitations?

Thanks, Radu


Solution

  • After more research I found a way to achieve this:

     List<int> videoIds = new List<int>(){1, 2, 3, 4, 5};
     SqlQuery query = new Select().From<Video>().Where("ID").In(videoIds);
     List<Video> videos = query.ExecuteTypedList<Video>();