internal void VerfityOutput(ComplexOutputInfo output) { if (output != null) { Debug.Assert(output.ItemFields.Length == 0 || output.ItemFields.Any(a => a > -1)); foreach (var item in output.Children.OfType <ComplexOutputInfo>()) { VerfityOutput(item); } } }
/// <summary> /// 根据分组检索表达式 SingleDefault 初始化查询输出语句及输出对象。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="current">所在数据源。</param> /// <param name="expression">初始化表达式。</param> /// <param name="parent">父级输出对象。</param> protected virtual void InitialRetrievalForSingleDefault(GenerateContext context, ISourceFragment current, DbRetrievalFunctionExpression expression, ComplexOutputInfo parent) { var select = current as SelectFragment; select.Take = 2; InitialRetrievalForFilter(context, expression, select); if (parent is ObjectOutputInfo output) { output.Option = EObjectOutputOption.ZeroOrOnlyOne; } }
/// <summary> /// 根据分组检索表达式初始化查询输出语句及输出对象。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="current">所在数据源。</param> /// <param name="expression">初始化表达式。</param> /// <param name="parent">父级输出对象。</param> public void InitialRetrieval(GenerateContext context, ISourceFragment current, DbRetrievalFunctionExpression expression, ComplexOutputInfo parent) { if (!_InitialRetrievalMethods.TryGetValue(expression.Function, out InitialRetrievalDelegate method)) { throw new NotSupportedException(string.Format(Res.NotSupportedInitialRetrieval, expression.Function)); } method(context, current, expression, parent); }
//分组检索表达式 ElementAt 实现。 private void InitialRetrievalForElementAtImp(GenerateContext context, ISourceFragment current, DbRetrievalFunctionExpression expression, ComplexOutputInfo parent, EObjectOutputOption option) { var value = expression.Arguments[0] as DbConstantExpression; var select = current as SelectFragment; select.Take = 1; select.Skip = (int)value.Value; if (select.Skip > 0 && select.Sorts.Count == 0) { var member = GetFirstMemberForOrder(select); select.Sorts.Add(new SortFragment(context, member)); } if (parent is ObjectOutputInfo output) { output.Option = option; } }
/// <summary> /// 根据分组检索表达式 ElementAtDefault 初始化查询输出语句及输出对象。 /// </summary> /// <param name="context">生成上下文。</param> /// <param name="current">所在数据源。</param> /// <param name="expression">初始化表达式。</param> /// <param name="parent">父级输出对象。</param> protected virtual void InitialRetrievalForElementAtDefault(GenerateContext context, ISourceFragment current, DbRetrievalFunctionExpression expression, ComplexOutputInfo parent) { InitialRetrievalForElementAtImp(context, current, expression, parent, EObjectOutputOption.ZeroOrOne); }