Skip to content

Instantly share code, notes, and snippets.

@smarenich smarenich/ScalarCount.cs
Last active May 5, 2016

What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PX.SM;
using PX.TM;
using PX.Data;
namespace PX.Objects.CR
public sealed class ScalarCount<Field> : IBqlFunction
where Field : IBqlField
public void GetAggregates(List<IBqlFunction> fields)
//Return this as count is aggregate function
public void Parse(PXGraph graph, List<IBqlParameter> pars, List<Type> tables, List<Type> fields, List<IBqlSortColumn> sortColumns, StringBuilder text, BqlCommand.Selection selection)
if (tables != null)
if (graph != null && text != null)
//adding count function to the field
StringBuilder bld = new StringBuilder("COUNT(DISTINCT ");
bld.Append(BqlCommand.GetSingleField(typeof(Field), graph, tables, selection, BqlCommand.FieldPlace.Condition));
public void Verify(PXCache cache, object item, List<object> pars, ref bool? result, ref object value) { }
//Return name of function
public string GetFunction() { return "COUNT"; }
//return name of field what we need to count
public Type GetField() { return typeof(Field); ; }
//it is not group by
public bool IsGroupBy() { return false; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.