Cannot implicitly convert from Anonymous type to generic List

263 views Asked by At

Three Tables:

Category - CID, CName,CParentID (when CParentID=0, its a Category; when CParentID > 0, its a SubCategory)
Product - PID,Title, Desc etc
Category_Product - CPID, CID, PID

Function:

        public List<T> GetProductCategory<T>(int id)
    {
        var Query = from ProductTable in objProductDataContext.Products
                             join CPTable in objProductDataContext.CategoryProducts on ProductTable.ProductID equals CPTable.ProductID
                             join CategoryTable in objProductDataContext.Categories on CPTable.CategoryID equals CategoryTable.CategoryID where ProductTable.ProductID==id
                             select new { ProductTable, CPTable, CategoryTable };
        return Query;
    }

I need to return this data to the controller. How can I do this? I read about creating a separate class, but I am not sure how I would do it in this case. The heading is the current error I am getting.

0

There are 0 answers