Custom Aggregate Function: AggConcat()
Review the documentation on Custom Aggregate Functions for full details on developing and implementing this function.
Program Code
public class AggJoin : ICustomAggregator { System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string delimiter = ", "; public void AddValue(SessionInfo sessionInfo, object value, params object[] args) { // Skip blank values if (value == null || value.ToString() == string.Empty) return; if (args.Length != 0) this.delimiter = args[0].ToString(); this.stringBuilder.Append(value); this.stringBuilder.Append(this.delimiter); } public object Result(SessionInfo sessionInfo) { string retVal = this.stringBuilder.ToString(); // Remove the trailing delimiter if (this.delimiter.Length > 0 && retVal.Length > 0) retVal = retVal.Remove(retVal.Length - this.delimiter.Length); return retVal; } }