---
title: "RVN003 - ProjectInto called more than once in a query chain"
description: "RVN003* reports repeated ProjectInto calls in the same RavenDB LINQ query chain."
url: "https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/RVN003"
version: "7.2"
---

# RVN003 - ProjectInto called more than once in a query chain

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - **RVN003** reports repeated `ProjectInto` calls in the same RavenDB LINQ query chain.
>
> - **Default severity**: *Info*  
>   **Automated code fix**: *No*
>
> - In this article:
>   - [Description](#description)
>   - [Trigger condition](#trigger-condition)
>     - [When is RVN003 reported?](#when-is-rvn003-reported)
>     - [When is RVN003 not reported?](#when-is-rvn003-not-reported)
>   - [How to resolve](#how-to-resolve)
>     - [Before (triggers RVN003)](#before-triggers-rvn003)
>     - [After (correct)](#after-correct)
>   - [Limitations](#limitations)
>   - [Related C# analyzers](#related-c-analyzers)

## Description {#description}

RavenDB allows only a [single projection per query](https://docs.ravendb.net/7.2/client-api/session/querying/how-to-project-query-results.md#single-projection-per-query),
whether the projection is defined with `ProjectInto<T>()` or `Select(...)`.

RVN003 detects repeated `ProjectInto` calls in the same LINQ query chain at compile time.  
Calling `ProjectInto` a second time throws `InvalidOperationException` ("*'ProjectInto' was already called…*")
as soon as the second call is made, because the projection is already registered on the query provider.

RVN003 does not report other combinations of projection methods, such as `ProjectInto` with `Select`.

## Trigger condition {#trigger-condition}

RVN003 checks RavenDB LINQ queries from synchronous or asynchronous sessions.

### When is RVN003 reported?

RVN003 is reported on each `ProjectInto` call that follows an earlier `ProjectInto` call in the same query chain.  
This includes a projected query stored in a local variable and projected again in a later statement.

The calls can target the same type or different types, and other query operators can appear between them.

### When is RVN003 not reported?

RVN003 is not reported for:

- A query with a single projection.
- A combination of `ProjectInto` and `Select`, or multiple `Select` calls.
- Separate `ProjectInto` calls that each start from the same local variable initialized with an unprojected query,
  rather than from the result of an earlier projection.

Separate branches are not necessarily independent query instances, so the absence of RVN003 does not guarantee
that reusing a LINQ query is safe. For the supported base-query reuse pattern, see [How to resolve](#how-to-resolve).

## How to resolve {#how-to-resolve}

Remove the duplicate `.ProjectInto` call.  
If you need additional fields, use a single projection type that contains the fields you need.

To run the same base query with multiple projections, keep the unprojected base query as a `DocumentQuery`  
(or `AsyncDocumentQuery` for an asynchronous session).  
Call `ToQueryable()` separately before each projection to create independent query instances.  
See [Reusing the same base query for multiple projections](https://docs.ravendb.net/7.2/client-api/session/querying/how-to-project-query-results.md#reusing-the-same-base-query-for-multiple-projections) for synchronous and asynchronous examples.

---

### Before (triggers RVN003)

```csharp
var projected = session.Query<Order>()
    .ProjectInto<OrderSummaryDto>();

var results = projected
    // Triggers RVN003: the local variable already holds a projected query.
    .ProjectInto<OrderDetailsDto>()
    .Take(50)
    .ToList();
```

### After (correct)

```csharp
var results = session.Query<Order>()
    .ProjectInto<OrderDetailsDto>()
    .Take(50)
    .ToList();
```

## Limitations {#limitations}

- RVN003 follows only the value a local variable is declared with; later assignments are not taken into account.
  Depending on the reassignment, this can miss a repeated projection or report one that is no longer present.

- RVN003 does not trace earlier projections through helper-method return values, parameters, fields, properties,  
  or C# query-syntax clauses. Explicit repeated calls in a visible chain can still be detected.

- Within a recognized RavenDB query chain, RVN003 identifies `ProjectInto` calls by name without verifying
  that they resolve to RavenDB's extension method. Custom methods with the same name can also cause a report.

## Related C# analyzers {#related-c-analyzers}

- [RVN002](https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/RVN002.md)  
  Reports certain query operators used after a projection, including a `Where` placed between two `ProjectInto` calls.

## See also

- [C# code analyzers overview](https://docs.ravendb.net/7.2/client-api/csharp-code-analyzers/overview.md)
- [Single projection per query](https://docs.ravendb.net/7.2/client-api/session/querying/how-to-project-query-results.md#single-projection-per-query)
- [Project index query results](https://docs.ravendb.net/7.2/indexes/querying/projections.md)
