Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot see FirstOrDefault

Tags:

c#

linq

Any Help is much appreciated guys!

under GetProductByID, i am getting an error saying "int does not contain a definition for FirstOrDefault".

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HomebaseSystemNew.Models;

namespace HomebaseSystemNew.Controllers
  {
    public class ProductRepository
   {

    public ProductsController GetProductID(int Pid)
        {
          Product db = new Product();

          return db.Pid.FirstOrDefault(db => db.Pid == Pid);
        }


   }




   }
like image 335
user892239 Avatar asked Oct 17 '11 12:10

user892239


1 Answers

Also You need to add using System.Linq namespace to access those methods.

like image 166
maxspan Avatar answered Oct 27 '22 16:10

maxspan