public void MultiColumnDynamicFilterTest() { var dynamicFilterId = new object(); var tableRef = SqlDml.TableRef(Catalog.Schemas["Person"].Tables["Contact"]); var select = SqlDml.Select(tableRef); select.Columns.Add(SqlDml.Count()); var filter = SqlDml.DynamicFilter(dynamicFilterId); select.Where = filter; filter.Expressions.Add(tableRef["FirstName"]); filter.Expressions.Add(tableRef["LastName"]); var result = sqlConnection.Driver.Compile(select); using (var command = sqlConnection.CreateCommand()) { var values = new List <string[]> { new[] { "'Gustavo'", "'Achong'" }, new[] { "'Catherine'", "'Abel'" } }; var configuration = new SqlPostCompilerConfiguration { DynamicFilterValues = { { dynamicFilterId, values } } }; command.CommandText = result.GetCommandText(configuration); int count = Convert.ToInt32(command.ExecuteScalar()); Assert.AreEqual(2, count); } }
protected SqlExpression CreateIncludeViaComplexConditionExpression( IncludeProvider provider, Func <object> valueAccessor, IList <SqlExpression> sourceColumns, out QueryParameterBinding binding) { var filterTupleDescriptor = provider.FilteredColumnsExtractionTransform.Descriptor; var mappings = filterTupleDescriptor.Select(type => Driver.GetTypeMapping(type)); binding = new QueryRowFilterParameterBinding(mappings, valueAccessor); var resultExpression = SqlDml.DynamicFilter(binding); resultExpression.Expressions.AddRange(provider.FilteredColumns.Select(index => sourceColumns[index])); return(resultExpression); }