One of the other things that you can do with the IRepositroy collection in SalesLogix is to perform a summation of a entity field after filtering for a group of records. Lets look at how to do this:
Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IOpportunity> repository =
Sage.Platform.Repository.ICriteria criteria = repository.CreateCriteria();
criteria.Add(repository.EF.Eq("Type", “Some Type”));
System.Collections.IList potential= criteria.List();
if (potential!= null) used = Convert.ToDouble(potential);
So in this example I have created a criteria condition looking for all Opportunities with a type=”Some Type” and a Status = “Open” from this I can then use the SetProjection method to sum the SalesPotential property. With that I return an IList. The IList is an arrayed list so my value will be the only returned value. On the final line I just check to ensure the list is not null and then return the first position array which is the sum of the potential for all of the opportunities meeting my conditions.