views:

60

answers:

0

When using SubSonic 3.0 i have encountered a small issue that may be quite easy to solved, but please, enlight me with the solution :)

I have a NewsArticle table with some news, each newsarticle can be published on different sites. So there is a Site table and also a NewsArticleSite table. The NewsArticleSite table contains a primary key (really not necessary but anyway...), a NewsArticleID and a SiteID.

I would like to have a query that have some criterias such as NewsArticle.Published is set but i would also like to filter on a specific Site. This query gives me an exception that the object needs to implement IConvertible

IQueryable<NewsArticle> articles = NewsArticle.All();
if (filterOnPublished)
{
    articles = articles.Where(x => x.Published != null);
}

if (filterOnSite)
{
    NewsArticleSite site = NewsArticleSite.SingleOrDefault(x => x.SiteID == siteId);
    articles = articles.Where(x => x.NewsArticleSites.Contains(site));
}

return articles.ToList();

This looks good to me and i have also tried putting the site querystuff into a single lambda but thats not working either.

Please...help!