Is it possible to combine multiple filters in Subsonic 2.1 to a shorter piece of code?
SubSonic.Where filterTaal = new SubSonic.Where();
filterTaal.ColumnName = Pagina.Columns.Taal;
filterTaal.Comparison = SubSonic.Comparison.Equals;
filterTaal.ParameterValue = taal;
SubSonic.Where filterKey = new SubSonic.Where();
filterKey.ColumnName = Pagina.Columns.PaginaKey;
filterKey.Comparison = SubSonic.Comparison.Equals;
filterKey.ParameterValue = paginaKey;
PaginaCollection paginaCollection = new PaginaCollection()
.Where(filterTaal)
.Where(filterKey)
.Load();
It seems to me that above code can be shorter?
You could write your own extension method and use ExpressionTrees.
Result will be something like this:
The extension method will be smth. like this:
And the helper methods will be:
WhereDummyis a dummy class only to provide more readable syntax, because.SlimWhere(paginaColumns.PaginaKey == paginaKey)is not so understandable.