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.
The DynamicParameters type provides an Add method, enabling you to pass explicit parameters, specifying the datatype, direction and size: var parameters = new DynamicParameters();
Dapper is an object–relational mapping (ORM) product for the Microsoft . NET platform: it provides a framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant portion of relational data persistence-related programming tasks.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With