Ok, I get an exception saying "Mod is not supported by SqlServer"? That doesn't make sense...
Note I am using the adapter model.
public DataTable FetchProviderOptions(int categoryID, int amount, int cutOffAmount)
{
ResultsetFields fields = new ResultsetFields(3);
RelationPredicateBucket bucket = new RelationPredicateBucket();
DataTable dtResults = new DataTable();
// define our fields to fetch.
fields[0] = ProviderFields.ProviderID;
fields[1] = ProviderFields.ImageName;
fields[2] = DenominationFields.Amount;
// add our entity joins.
bucket.Relations.Add(ProviderEntity.Relations.Provider_DenominationEntityUsingProviderID);
bucket.Relations.Add(Provider_DenominationEntity.Relations.DenominationEntityUsingDenominationID);
// build our predicates for the provider table.
bucket.PredicateExpression.Add(ProviderFields.Active == true);
bucket.PredicateExpression.AddWithAnd(ProviderFields.ProviderCategoryID == categoryID);
// build our predicates for the denomination table.
bucket.PredicateExpression.AddWithAnd(DenominationFields.Active == true);
bucket.PredicateExpression.AddWithAnd(DenominationFields.Amount <= amount);
bucket.PredicateExpression.AddWithAnd(DenominationFields.Amount >= cutOffAmount);
IEntityField2 field = new EntityField2("Result", new Expression(amount, ExOp.Mod, DenominationFields.Amount));
bucket.PredicateExpression.AddWithAnd(new FieldCompareValuePredicate(field, null, ComparisonOperator.Equal, 0));
// perform our fetch.
base.DataAccessAdapter.FetchTypedList(fields, dtResults, bucket, 0,
new SortExpression(ProviderFields.ProviderNm | SortOperator.Ascending) & (DenominationFields.Amount | SortOperator.Ascending), false);
return dtResults;
}