DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | List of all members
Deveel.Data.Routines.SystemFunctionsProvider.Count Class Reference

Static Public Member Functions

static InvokeResult Execute (InvokeContext context)
 

Detailed Description

Definition at line 157 of file SystemFunctionsProvider.cs.

Member Function Documentation

static InvokeResult Deveel.Data.Routines.SystemFunctionsProvider.Count.Execute ( InvokeContext  context)
inlinestatic

Definition at line 158 of file SystemFunctionsProvider.cs.

158  {
159  if (context.GroupResolver == null)
160  throw new Exception("'count' can only be used as an aggregate function.");
161 
162  int size = context.GroupResolver.Count;
163  DataObject result;
164  // if, count(*)
165  if (size == 0 || context.Invoke.IsGlobArgument) {
166  result = DataObject.Integer(size);
167  } else {
168  // Otherwise we need to count the number of non-null entries in the
169  // columns list(s).
170 
171  int totalCount = size;
172 
173  var exp = context.Arguments[0];
174  for (int i = 0; i < size; ++i) {
175  var val = exp.EvaluateToConstant(context.Request, context.GroupResolver.GetVariableResolver(i));
176  if (val.IsNull) {
177  --totalCount;
178  }
179  }
180 
181  result = DataObject.Integer(totalCount);
182  }
183 
184  return context.Result(result);
185  }
static DataObject Integer(int value)
Definition: DataObject.cs:576
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35

The documentation for this class was generated from the following file: