/// <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="ODataQueryContext"/> which contains the <see cref="IEdmModel"/> and some type information.</param> /// <param name="queryOptionParser">The <see cref="ODataQueryOptionParser"/> 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()); } Context = context; RawSelect = select; RawExpand = expand; Validator = new SelectExpandQueryValidator(); _queryOptionParser = queryOptionParser; }
// This constructor is intended for unit testing only. internal 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()); } Context = context; RawSelect = select; RawExpand = expand; Validator = new SelectExpandQueryValidator(); _queryOptionParser = new ODataQueryOptionParser( context.Model, context.ElementType, context.NavigationSource, new Dictionary<string, string> { { "$select", select }, { "$expand", expand } }); }