1
當我將返回值設置爲List
時,我有一個LINQ查詢,但我只想返回一個IQueryable<Post>
。我會怎麼做?從LINQ查詢中返回一個對象而不會將其轉換爲列表
public List<Post> GetPostByID(int id)
{
var thePost = (from p in _context.Posts
where p.Id == id
select p).ToList();
return thePost;
}