Joab Santos
Joab Santos

Reputation: 522

How to call SQL View Dapper c#

Is there any way to call a sql view by using Dapper c# ?

I already know how to call stored procedures with that, but when it comes to views I have no idea how to do that.

Upvotes: 9

Views: 11138

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062780

A view works like a table from the perspective of queries, including how filters and parameters work - so something like:

string region = ...
var data = connection.Query<SomeType>(
    "select * from SomeView where Region = @region", new { region }).AsList();

Upvotes: 12

Related Questions