开发者

Unable to specify Out T in my IQueryable<T>

开发者 https://www.devze.com 2023-04-12 10:21 出处:网络
I\'m following the NerdDinner tutorial for MVC and have a question about setting up my repository.Here\'s what I have so far...

I'm following the NerdDinner tutorial for MVC and have a question about setting up my repository. Here's what I have so far...

using System;
using System.Collections.Generic;
using System.Linq;


namespace BusinessReviews.Models
{
    public class ReviewsRepository
    {
        private BusinessReviewsDataContext db = new BusinessReviewsDataContext();


        public IQueryable GetAllBusinesses()
        {
            return db.Businesses;
        }
    }

}

I know that my IQueryable should specify T. In the tutorial开发者_如何学JAVA they put the table name where the T is, which in their case was "Dinner". For my application I think it should be "Business". Unfortunately Visual Studio is not recognizing the Business class. Any ideas on what could be wrong?

*Edit --- per comment below, here's what I am trying to write

public IQueryable<Business> GetAllBusinesses()
{
return db.Businesses;
}


Typically the error "Unknown type __" is caused by namespace problems. Make sure you are including the appropriate namespaces. When working with generated code it is helpful to look at the generated classes by examining the designer.cs files. There may also be instances where the name isn't what you expected for some reason.


You can only specify an out T when defining an interface. What you are defining is a method.

public interface IMyInterface<out T>
{
    T GetSomething();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号