This is the code :
ResultsetFields fields = new ResultsetFields(3);
fields.DefineField(RemittanceBatchFields.BatchNumber, 0);
fields.DefineField(RemittanceBatchFields.TotalAmount, 1);
RelationCollection relationPosted = new RelationCollection();
relationPosted.Add(RemittanceEntity.Relations.RemittanceAllocationEntityUsingRemittanceFkid, JoinHint.Inner);
fields.DefineField(new EntityField2("TotalPosted", new ScalarQueryExpression(
RemittanceAllocationFields.AppliedAmount.SetAggregateFunction(AggregateFunction.Sum),
RemittanceBatchFieldsFields.Id == RemittanceFields.RemittanceBatchFkid, relationPosted)), 2);
List<BatchSummaryDomain> results = new List<BatchSummaryDomain>();
DataProjectorToCustomClass<BatchSummaryDomain> projector =
new DataProjectorToCustomClass<BatchSummaryDomain>(results);
List<IDataValueProjector> valueProjectors = new List<IDataValueProjector>();
valueProjectors.Add(new DataValueProjector("BatchNumber", 0, typeof(string)));
valueProjectors.Add(new DataValueProjector("BatchTotal", 1, typeof(decimal)));
valueProjectors.Add(new DataValueProjector("TotalPostedInvoice", 2, typeof(decimal)));
Using (DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchProjection(valueProjectors, projector, fields,
bucket, searchCriteria.Pager.MaximumRecords,
sortExpression,false,
searchCriteria.Pager.PageIndex, searchCriteria.Pager.PageSize);
}
The ScalarQueryExpression is adding TOP 1 to the sub query.
Is there any way to get rid of TOP clause or is there any other way to use a sub query? I am using version 2.0