views:

97

answers:

1

I have a repository class and it has this,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrMVC.BusinessObjects;

namespace CrMVC.Models
{
    public class ConstructionRepository
    {
        private CRDataContext db = new CRDataContext();

        public IQueryable<MaterialsObj> FindAllMaterials()
        {
           var materials =  from m in db.Materials
             join Mt in db.MeasurementTypes on m.MeasurementTypeId equals Mt.Id
                select new MaterialsObj()
                   {
                       Id = Convert.ToInt64(m.Mat_id),
                       Mat_Name = m.Mat_Name,
                       Mes_Name = Mt.Name,
                   };
            return materials;

        }
    }
 }

And My MaterialsObj class is under CrMVC.BusinessObjects namespace and i using it in my repository class....

namespace CrMVC.BusinessObjects
{
    public class MaterialsObj
    {
         //My logic here
    }
}

But when i compile this i get this error

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\19360d4c\3d21e226\App_Web_materials.aspx.7d2669f4.a8f-zsw5.0.cs(148):
error CS0426: The type name 'Materials' does not exist 
 in the type 'CrMVC.Models.ConstructionRepository'

Am i missing something any suggestion....

Edit:

There is no class named Materials in my repository class then why i get this error..

My view page has this,

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
 Inherits="System.Web.Mvc.ViewPage<IEnumerable<CrMVC.Models.ConstructionRepository+Materials>>" %>
+1  A: 

You are referencing the type CrMVC.Models.ConstructionRepository.Materials in your ASPX when you probably want to reference CrMVC.BusinessObjects.MaterialsObj instead.

Daniel Renshaw