0

刚开始弄乱存储库/接口等,在选择一条我无法解决的记录时出现错误。

我的控制器有:

    public ViewResult Detail(int ID)
    {
        var Details = (from x in repo.GetBreakdown(ID) select new BreakdownDetailViewModel { }).SingleOrDefault();

        return View(Details);
    }

语句 repo.GetBreakdown(ID) 带有以下错误的下划线:

Could not find an implementation of the query pattern for source type ''. 'Select' not found.

我的界面显示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Entities;

namespace Domain.Abstract
{
    public interface IBreakdownRepository
    {
        tblBreakdown_Log GetBreakdown(int ID);
        IQueryable<tblBreakdown_Log> GetAllBreakdowns { get; }

    }
}

存储库本身具有:

 public tblBreakdown_Log GetBreakdown(int ID)
        {
            return (from x in db.tblBreakdown_Logs where x.MB_ID == ID select x).SingleOrDefault();
    }

关于这里的问题有什么想法吗?

谢谢,克里斯

4

1 回答 1

0

基于@Evan 的评论

将我的存储库访问更改为:

    public IEnumerable<tblBreakdown_Log> GetBreakdown(int ID)
        {
            return (from x in db.tblBreakdown_Logs where x.MB_ID == ID select x);
        }

存储库的接口现在具有:

 IEnumerable<tblBreakdown_Log> GetBreakdown(int ID);

我的控制器访问权限是:

 public ViewResult Detail(int ID)
        {
        var Details = (from x in repo.GetBreakdown(ID) select new BreakdownDetailViewModel {Machine_Status=x.tblMachine_Status.Machine_Status, MB_ID=x.MB_ID});

        return View(Details);
    }

现在所有工作都按需要工作=]

于 2012-12-20T09:03:33.147 回答