title: How can I map a Row to a class using Anorm?
body: <p>I have a class <code>User</code>:</p>
  
  <pre><code>case class User (id: Int, name: String)
  </code></pre>
  
  <p>And I would like to map the rows from a query using <a href="http://scala.playframework.org/documentation/scala-0.9.1/anorm#RetrievingdatausingtheStreamAPI" rel="nofollow">Anorm Stream API</a>. I have tried with this code:</p>
  
  <pre><code>val selectUsers = SQL("SELECT id, name FROM users")
  val users = selectUsers().map(
      user =&gt; User(0, user.name)
  ).toList
  </code></pre>
  
  <p>But I get an error: </p>
  
  <pre><code>Error raised is : value name is not a member of play.db.anorm.SqlRow
  </code></pre>
  
  <p>on</p>
  
  <pre><code>user =&gt; User(0, user.↓name)
  </code></pre>
  
  <p>How can I map the <code>SqlRow</code> to a class?</p>
  
  <hr>
  
  <p>As suggested by Ricardo, I tried:</p>
  
  <pre><code>object User extends Magic[User]
  
  val users: List[User] = SQL("SELECT * FROM users").as(User*)
  </code></pre>
  
  <p>But with this code I get an <code>RuntimeException occured : ColumnNotFound(User.id)</code> on:</p>
  
  <pre><code>val users: List[User] = SQL("SELECT * FROM users").as(User*)
  </code></pre>
  
  <p>Any suggestions? Am I supposted to have the <code>User</code> object in the line right before? and I still have my <code>case class User</code>.</p>