Skip to content

Commit

Permalink
Ordering Caveat in FromSql (#2599)
Browse files Browse the repository at this point in the history
* doc: ordering issue in FromSql

* Accept revision from @JeremyLikness
  • Loading branch information
nbuuck committed Sep 8, 2020
1 parent c5bfe4a commit d7b80ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions entity-framework/core/querying/raw-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ You can also construct a DbParameter and supply it as a parameter value. Since a

[!code-csharp[Main](../../../samples/core/Querying/RawSQL/Sample.cs#FromSqlRawStoredProcedureNamedSqlParameter)]

> [!NOTE]
> **Parameter Ordering**
> Entity Framework Core passes parameters based on the order of the `SqlParameter[]` array. When passing multiple `SqlParameter`s, the ordering in the SQL string must match the order of the parameters in the stored procedure's definition. Failure to do this may result in type conversion exceptions and/or unexpected behavior when the procedure is executed.
## Composing with LINQ

You can compose on top of the initial raw SQL query using LINQ operators. EF Core will treat it as subquery and compose over it in the database. The following example uses a raw SQL query that selects from a Table-Valued Function (TVF). And then composes on it using LINQ to do filtering and sorting.
Expand Down

0 comments on commit d7b80ac

Please sign in to comment.