// This constructor is intended for unit testing only. private SelectExpandQueryOption(string select, string expand, ODataQueryContext context) { if (context == null) { throw Error.ArgumentNull("context"); } if (String.IsNullOrEmpty(select) && String.IsNullOrEmpty(expand)) { throw Error.Argument(SRResources.SelectExpandEmptyOrNull); } IEdmEntityType entityType = context.ElementType as IEdmEntityType; if (entityType == null) { throw Error.Argument("context", SRResources.SelectNonEntity, context.ElementType.ToTraceString()); } this.Context = context; this.RawSelect = select; this.RawExpand = expand; this.Validator = SelectExpandQueryValidator.GetSelectExpandQueryValidator(context); this._queryOptionParser = new ODataQueryOptionParser( context.Model, context.ElementType, context.NavigationSource, new Dictionary <string, string> { { "$select", select }, { "$expand", expand } }, context.RequestContainer); }
/// <summary> /// Initializes a new instance of the <see cref="SelectExpandQueryOption"/> class. /// </summary> /// <param name="select">The $select query parameter value.</param> /// <param name="expand">The $expand query parameter value.</param> /// <param name="context">The <see cref="IEdmModel"/> which contains the <see cref="IEdmModel"/> and some type information.</param> /// <param name="queryOptionParser">The <see cref="ODataQueryContext"/> which is used to parse the query option.</param> public SelectExpandQueryOption(string select, string expand, ODataQueryContext context, ODataQueryOptionParser queryOptionParser) { if (context == null) { throw Error.ArgumentNull("context"); } if (String.IsNullOrEmpty(select) && String.IsNullOrEmpty(expand)) { throw Error.Argument(SRResources.SelectExpandEmptyOrNull); } if (queryOptionParser == null) { throw Error.ArgumentNull("queryOptionParser"); } IEdmEntityType entityType = context.ElementType as IEdmEntityType; if (entityType == null) { throw Error.Argument("context", SRResources.SelectNonEntity, context.ElementType.ToTraceString()); } this.Context = context; this.RawSelect = select; this.RawExpand = expand; this.Validator = SelectExpandQueryValidator.GetSelectExpandQueryValidator(context); this._queryOptionParser = queryOptionParser; }