protected virtual object EvalQuery(object item, NPathSelectQuery query) { NPathClassName className = (NPathClassName)query.From.Classes[0]; string propertyPath = className.Name; IList childList = (IList)EvalStringPropertyPath(item, propertyPath); ArrayList result = InternalGetTable(query, childList); object[] resultList = new object[result.Count]; int i = 0; foreach (object[] values in result) { object scalarRes = values[0]; if (IsNumber(scalarRes)) { scalarRes = double.Parse(scalarRes.ToString()); } resultList[i] = scalarRes; i++; } if (query.IsAggregate) { return(resultList[0]); } else { return(resultList); } }
public void ExpandWildcards(NPathSelectQuery query) { ArrayList newSelectFieldList = new ArrayList(); foreach (NPathSelectField field in query.Select.SelectFields) { string fieldName = field.Alias; NPathIdentifier path = field.Expression as NPathIdentifier; if (path != null && path.IsWildcard) { string[] parts = path.Path.Split('.'); NPathClassName className = (NPathClassName)query.From.Classes[0]; IClassMap classMap = Context.DomainMap.MustGetClassMap(className.Name); int i = 0; foreach (string part in parts) { if (i == parts.Length - 1) { break; } IPropertyMap property = classMap.MustGetPropertyMap(part); classMap = Context.DomainMap.MustGetClassMap(property.DataType); i++; } ArrayList properties = classMap.GetAllPropertyMaps(); foreach (PropertyMap property in properties) { if (property.ReferenceType != ReferenceType.None) { continue; } NPathSelectField newField = new NPathSelectField(); newField.Alias = null; NPathIdentifier newPath = new NPathIdentifier(); if (parts.Length > 1) { newPath.Path = string.Join(".", parts, 0, parts.Length - 1) + "."; } newPath.Path += property.Name; newField.Expression = newPath; newSelectFieldList.Add(newField); } } else { newSelectFieldList.Add(field); } } query.Select.SelectFields = newSelectFieldList; }
private void ParseFromClause(NPathFromClause fromClause) { do { tokenizer.MoveNext(); Token classToken = tokenizer.GetCurrentToken("identifier", "Class name"); // do not localize NPathClassName className = new NPathClassName(); className.Name = classToken.Text; fromClause.Classes.Add(className); tokenizer.MoveNext(); } while (tokenizer.GetCurrentToken().IsType("comma")); }