Skip to content
Advertisement

How to map/join two tables and filter by parameters using dapper

I want to join two tables that have a relationship with each other, In the Customer table, there are two columns for deleted and approved. Get the Customer that are approved and not deleted then match the Customer with the Loan table Using CustId (Both Tables has CustId) and Filter by supplied parameters

  • Deleted=0
  • Approved=1

Passed Parameters are(And they can be optional) User can pass only one or two or more than 2 InterestRate LoanTrfDate LastPaymentDate

Advertisement

Answer

to filter by a parameter only if it’s not null, you can use the SQL below.

to check that at least one parameter was set, you can add this if statement.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement