-
Notifications
You must be signed in to change notification settings - Fork 6
Simple Retrieve
Max Stepanskiy edited this page Mar 31, 2021
·
13 revisions
- Maps ADO.NET results to specified DTO's
- Executes direct SQL statements when a sql parameter is passed
- Otherwise executes a stored procedure based on the configurable naming convention and optional operation parameter value
Use various types of dynamic parameters
// Executes RetrieveCustomer stored procedure given provided configuration
ConfigurationFactory.Configure().SetDefaultOperationNamingConvention(OperationNamingConvention.OperationTypeName);
// Parameters can be defined as a list of lambda expressions
var retrieve_customer_dyn1 = ObjectFactory.Retrieve<Customer>(parameters: new ParamList { CustomerID => "ALFKI" });
// Parameters can be defined as an anonymous object
var retrieve_customer_dyn2 = ObjectFactory.Retrieve<Customer>(parameters: new { CustomerID = "ALFKI" });
// Parameters can be defined as dictionary
var retrieve_customer_dyn3 = ObjectFactory.Retrieve<Customer>(parameters: new Dictionary<string, object> { { "CustomerID", "ALFKI" } });
// Executes RetrieveCustomer stored procedure given provided configuration
ConfigurationFactory.Configure().SetDefaultOperationNamingConvention(OperationNamingConvention.OperationTypeName);
var retrieve_customer = ObjectFactory.Retrieve<Customer>(parameters: new[] { new Param { Name = "CustomerID",
Value = "ALFKI" } });
// Executes RetrieveCustomersByCountrystored procedure by default
var retrieve_customers_by_country = ObjectFactory.Retrieve<Customer>(operation: "RetrieveCustomersByCountry",
parameters: new ParamList { Country => "USA" });
var retrieve_customer_sql = ObjectFactory.Retrieve<Customer>(
sql: "select * from Customers where CustomerID = @CustomerID",
parameters: new ParamList { CustomerID => "ALFKI" });
Click here for advanced retrieve features.