无法隐式转换类型与IEnumerable的 [英] Cannot implicitly convert type with IEnumerable

查看:145
本文介绍了无法隐式转换类型与IEnumerable的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我对这个MVC应用程序隆隆沿和所有运行平稳。我起身去修复吃点东西,下一次我建立我招呼着这些错误4:

So I'm chugging along on this MVC application and all is running smoothly. I get up to fix a bite to eat and the next time I build I'm greeted with 4 of these errors:

> Error 16  Cannot implicitly convert type
> 'System.Collections.Generic.IEnumerable<>
> [c:\Program Files (x86)\Reference  Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll]'
> to
> 'System.Collections.Generic.IEnumerable<>
> [c:\Program Files (x86)\Reference  Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll]'.
> An explicit conversion exists (are you missing a cast?)

请记住,实际上是有东西的IEnumerable&LT;>,我只是删除它。

Keep in mind that there is actually something in IEnumerable<>, I just removed it.

这是2类,其中的误差是在

This is the 2 classes where the errors are at

    public partial class PriceListController : Controller
    {

        [CanonicalUrlAttribute("PriceList")]
        [CompressionFilter(Order = 1)]
        [CacheFilter(Duration = 120, Order = 2)]
        public virtual ActionResult Index()
        {
            GodsCreationTaxidermyEntities context = new GodsCreationTaxidermyEntities();
            var viewModel = new PriceListViewModel() { PriceListAnimals = context.GetAnimalListForPriceList() };
            return View(viewModel);
        }


        [CompressionFilter(Order = 1)]
        [CacheFilter(Duration = 120, Order = 2)]
        public virtual ActionResult List(string animal)
        {
            GodsCreationTaxidermyEntities context = new GodsCreationTaxidermyEntities();

            var viewModel = new PriceListIndexViewModel() { AnimalPrices = context.GetPriceListByAnimal(animal) };
            return View(viewModel);
        }

    }
public partial class GalleryController : Controller
{
    //
    // GET: /Gallery/
    [CanonicalUrlAttribute("Gallery")]
    [CompressionFilter(Order = 1)]
    [CacheFilter(Duration = 120, Order = 2)]
    public virtual ActionResult Index()
    {
        GodsCreationTaxidermyEntities context = new GodsCreationTaxidermyEntities();
        var viewModel = new GalleryIndexViewModel() { GalleryAnimals = context.GetAnimalListForGallery() };
        return View(viewModel);
    }


    [CompressionFilter(Order = 1)]
    [CacheFilter(Duration = 120, Order = 2)]
    public virtual ActionResult List(string animal)
    {
        GodsCreationTaxidermyEntities context = new GodsCreationTaxidermyEntities();

        var viewModel = new GalleryListViewModel() { GalleryImages = context.GetGalleryImageByAnimal(animal) };
        return View(viewModel);

    }

}

我检查了DAL和信息库,并从那里传来任何错误。

I've checked the DAL and Repository and no errors coming from there.

推荐答案

得到这些错误解决了,这是我的错,因为我打电话从DAL /存储库错误的方法。

Got those errors resolved, it was my fault because I was calling the wrong methods from the DAL/Repository.

这篇关于无法隐式转换类型与IEnumerable的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆