title: Entity Framework "FromSqlRaw or FromSqlInterpolated was called with non-composable SQL and with a query composing over it." error for a return object
body: <p>I have this view</p>
  <pre><code>[Table(&quot;vw_Entity&quot;, Schema = &quot;c&quot;)]
  public partial class vw_Entity : BaseEntity
  {
      public long? PredictedEntityTypeID { get; set; } 
      public bool IsManuallyChanged { get; set; } 
  }
  </code></pre>
  <p>where <code>BaseEntity</code> is the class that stores only my <code>ID</code> and <code>UUID</code>.</p>
  <p>This is my DTO return object:</p>
  <pre><code>public class EntityDTO
  {
      public long ID { get; set; }
      public LookupTableDetails PredictedEntityTypeId { get; set; }
      public bool IsManuallyChanged { get; set; }
  }
  </code></pre>
  <p>where <code>LookupTableDetails</code> looks like:</p>
  <pre><code>public class LookupTableDetails
  {
      public long Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  <p>Now I have this stored procedure that does basically a <code>PATCH</code>. I call it using the following snippet:</p>
  <pre><code>var data = await _context.vw_Entity.FromSqlRaw(&quot;EXECUTE core.Update_Entity @EntityID&quot;, parameters)
                  .Select(x =&gt; new EntityDTO()
                  {
                      ID = x.ID,
                      PredictedEntityTypeId = new LookupTableDetails() { Id = x.PredictedEntityTypeId, Name = x.PredictedEntityTypeId == 1 ? &quot;Entity1&quot; : &quot;Entity2&quot; },
                      IsManuallyChanged = x.IsManuallyChanged
                  }).ToListAsync();
  </code></pre>
  <p>However, this crashes with an error</p>
  <blockquote>
  <p>FromSqlRaw or FromSqlInterpolated was called with non-composable SQL and with a query composing over it</p>
  </blockquote>
  <p>I'm aware what this error does, if I have a object of some other class inside my view then the stored procedure couldn't map it properly and return the error but in this case, my view is clear from obstacles of that type and all I need to do is just return the <code>LookupTableDetails</code> in my <code>DTO</code> object. The error is in</p>
  <pre><code>PredictedEntityTypeId = new LookupTableDetails() { Id = x.PredictedEntityTypeId, Name = x.PredictedEntityTypeId == 1 ? &quot;Entity1&quot; : &quot;Entity2&quot; }
  </code></pre>
  <p>I tried most of the solutions that the Internet offers, such as wrapping it with <code>IgnoreFilters..</code>, <code>AsEnumerable()</code> etc.</p>
  <p>Any ideas what is the cause and how can I prevent it from happening again in the future i.e fix it? :D</p>