Review the documentation on Custom Aggregate Functions for full details on developing and implementing this function.
Description | Returns a concatenated string of values separated by a specified delimiter string. |
---|---|
Arguments |
|
Namespaces |
|
Example | AggConcat({Categories.CategoryName}, ":") Beverages:Condiments:Seafood AggConcat({Categories.CategoryName}) Beverages, Condiments, Seafood |
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; } }