title: Database Queries in MVC Model
body: <p>In a MVC project if I put <strong>LINQ</strong> queries in <code>Model</code>, is it against the MVC Pattern?</p>
  
  <pre><code>namespace DocLibrary.Models
  {
      public class Author
      {
          private DocLibraryContext db = new DocLibraryContext();
  
          [Key]
          public Int32 AuthorId { get; set; }
  
          [StringLength(20)]
          public String Name { get; set; }
  
          ..
  
          public string GetNameById(int AuthorId)
          {
              var query = from a in db.Author
                          where a.AuthorId == AuthorId
                          select a.Name;
  
              return query.FirstOrDefault();
          }
  
  
          public Author GetAuthorById(int AuthorId)
          {
              var query = from a in db.Author
                          where a.AuthorId.Equals(AuthorId)
                          select a;
  
              return query.FirstOrDefault();
          }
      }
  </code></pre>
  
  <p>Or should I move these methods (<code>GetNameById</code>, <code>GetAuthorById</code>) to Controller?</p>