linq to sql -> join

Posted by ile on Stack Overflow See other posts from Stack Overflow or by ile
Published on 2010-03-22T23:55:01Z Indexed on 2010/03/23 0:11 UTC
Read the original article Hit count: 754

Filed under:
|
|
|

SQL query:

SELECT     ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date
FROM         ArticleCategories INNER JOIN
                   Articles ON ArticleCategories.CategoryID = Articles.CategoryID

Object repository:

public class ArticleRepository
    {
        private DB db = new DB();
        //
        // Query Methods
        public IQueryable<Article> FindAllArticles()
        {
            var result =   from category in db.ArticleCategories
                           join article in db.Articles on category.CategoryID equals article.CategoryID
                           select new
                           {
                               CategoryID = category.CategoryID,
                               CategoryTitle = category.Title,

                               ArticleID = article.ArticleID,
                               ArticleTitle = article.Title,
                               ArticleDate = article.Date,
                               ArticleContent = article.Content
                           };

            return result;

        }
        ....
    }

And finally, I get this error:

Error 1 Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?) C:\Documents and Settings\ilija\My Documents\Visual Studio 2008\Projects\CMS\CMS\Models\ArticleRepository.cs 29 20 CMS

Any idea what did I do wrong?

Thanks,
Ile

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about asp.net-mvc