A
A
Anniktar2017-03-05 21:17:30
C++ / C#
Anniktar, 2017-03-05 21:17:30

ASP.NET MVC, how to correctly compose a database query?

Table 1 - Forum :

  1. idForum (key)
  2. Name

Table 2 - Topic :
  1. idTopic(key)
  2. NameTopic
  3. idForum (related tables).

How to correctly compose a query to display the values ​​of the Topic table by idForum?
At the moment the request is:
return _db.Topic.Where(it => it.IdForum == id).Take(5);

Gives an error: "Unable to implicitly convert type. Explicit conversion exists (probably missing a cast)"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FreeBa, 2017-03-10
@FreeBa

And the method from which return is made exactly has a return type IQueryable<Topic>? And in the future, exactly is the processing of IQueryable, and not IEnumerable?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question