Note that there are some explanatory texts on larger screens.

plurals
  1. PORavenDB - Transformers have odd behaviors
    primarykey
    data
    text
    <p>In an attempt to utilize <code>RavenDB</code> and perform a transformer on a query, I am getting a bit of a strange behavior. </p> <p>Assuming a class <code>Member</code>, that is rather long and verbose...</p> <pre><code>class Member { // ... // Lots of properties, methods } </code></pre> <p>I just want to get a more lightweight result of them. So I declare a smaller class.</p> <pre><code>public class MiniMember { public string Id { get; set; } public string Name { get; set; } } </code></pre> <p>And attempt to query it with an <code>AbstractTransformerCreationTask&lt;T&gt;</code>.</p> <pre><code>public class MemberByNameList : AbstractTransformerCreationTask&lt;Member&gt; { public MemberByNameList() { TransformResults = members =&gt; from member in members select new MiniMember { Id = member.Id, Name = member.Name }; } } </code></pre> <p>This works fine on the server side Studio UI, but when I attempt to do this in my <code>.NET</code> code, I get problems.</p> <pre><code> var members = DocumentSession .Query&lt;Member&gt;() .TransformWith&lt;Indexes.MemberByNameList, MiniMember&gt;() .Take(512) .ToList(); </code></pre> <p>I am told that <code>Member</code> cannot be cast to class <code>MiniMember</code>.</p> <p>I have followed the examples on the RavenDB documentation very closely, and still receive this result, so I am extremely confused about this. </p> <h1><a href="http://ravendb.net/docs/2.5/client-api/querying/results-transformation/result-transformers" rel="nofollow">RavenDB Documentation on Result Transformers</a></h1>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload