@@ -393,6 +393,74 @@ public string GetSelectMethod(string requestType)
393393 return stringBuilder.ToString();
394394}
395395
396+ public string GetSelectExpressionMethod(string requestType, string underlyingType)
397+ {
398+ var stringBuilder = new StringBuilder();
399+
400+ stringBuilder.Append(
401+ @"/// <summary>
402+ /// Adds the specified select value to the request.
403+ /// </summary>
404+ /// <param name=""selectExpression"">The expression from which to calculate the select value.</param>
405+ /// <returns>The request object to send.</returns>");
406+ stringBuilder.Append(Environment.NewLine);
407+ stringBuilder.AppendFormat(" public I{0} Select(Expression<Func<{1}, object>> selectExpression)", requestType, underlyingType);
408+ stringBuilder.Append(@"
409+ {
410+ if (selectExpression == null)
411+ {
412+ throw new ArgumentNullException(nameof(selectExpression));
413+ }
414+ string error;
415+ string value = ExpressionExtractHelper.ExtractMembers(selectExpression, out error);
416+ if (value == null)
417+ {
418+ throw new ArgumentException(error, nameof(selectExpression));
419+ }
420+ else
421+ {
422+ this.QueryOptions.Add(new QueryOption(""$select"", value));
423+ }
424+ return this;
425+ }");
426+
427+ return stringBuilder.ToString();
428+ }
429+
430+ public string GetExpandExpressionMethod(string requestType, string underlyingType)
431+ {
432+ var stringBuilder = new StringBuilder();
433+
434+ stringBuilder.Append(
435+ @"/// <summary>
436+ /// Adds the specified expand value to the request.
437+ /// </summary>
438+ /// <param name=""expandExpression"">The expression from which to calculate the expand value.</param>
439+ /// <returns>The request object to send.</returns>");
440+ stringBuilder.Append(Environment.NewLine);
441+ stringBuilder.AppendFormat(" public I{0} Expand(Expression<Func<{1}, object>> expandExpression)", requestType, underlyingType);
442+ stringBuilder.Append(@"
443+ {
444+ if (expandExpression == null)
445+ {
446+ throw new ArgumentNullException(nameof(expandExpression));
447+ }
448+ string error;
449+ string value = ExpressionExtractHelper.ExtractMembers(expandExpression, out error);
450+ if (value == null)
451+ {
452+ throw new ArgumentException(error, nameof(expandExpression));
453+ }
454+ else
455+ {
456+ this.QueryOptions.Add(new QueryOption(""$expand"", value));
457+ }
458+ return this;
459+ }");
460+
461+ return stringBuilder.ToString();
462+ }
463+
396464public string GetExpandMethod(string requestType)
397465{
398466 var stringBuilder = new StringBuilder();
@@ -415,25 +483,37 @@ public string GetExpandMethod(string requestType)
415483}
416484
417485// Standard entity
418- public string GetEntityExpandMethod (OdcmClass odcmClass)
486+ public string GetEntityExpandMethods (OdcmClass odcmClass)
419487{
420- return this.GetExpandMethod(this.GetRequestString(this.GetEntityNameString(odcmClass)));
488+ string entityName = this.GetEntityNameString(odcmClass);
489+ return this.GetExpandMethod(this.GetRequestString(entityName)) +
490+ Environment.NewLine + Environment.NewLine + " " +
491+ this.GetExpandExpressionMethod(this.GetRequestString(entityName), entityName);
421492}
422493
423- public string GetEntitySelectMethod (OdcmClass odcmClass)
494+ public string GetEntitySelectMethods (OdcmClass odcmClass)
424495{
425- return this.GetSelectMethod(this.GetRequestString(this.GetEntityNameString(odcmClass)));
496+ string entityName = this.GetEntityNameString(odcmClass);
497+ return this.GetSelectMethod(this.GetRequestString(entityName)) +
498+ Environment.NewLine + Environment.NewLine + " " +
499+ this.GetSelectExpressionMethod(this.GetRequestString(entityName), entityName);
426500}
427501
428502// Entity with references
429- public string GetEntityWithReferenceExpandMethod (OdcmClass odcmClass)
503+ public string GetEntityWithReferenceExpandMethods (OdcmClass odcmClass)
430504{
431- return this.GetExpandMethod(this.GetEntityWithReferenceRequestName(odcmClass));
505+ string entityWithReferenceRequestName = this.GetEntityWithReferenceRequestName(odcmClass);
506+ return this.GetExpandMethod(entityWithReferenceRequestName) +
507+ Environment.NewLine + Environment.NewLine + " " +
508+ this.GetExpandExpressionMethod(entityWithReferenceRequestName, this.GetEntityNameString(odcmClass));
432509}
433510
434- public string GetEntityWithReferenceSelectMethod (OdcmClass odcmClass)
511+ public string GetEntityWithReferenceSelectMethods (OdcmClass odcmClass)
435512{
436- return this.GetSelectMethod(this.GetEntityWithReferenceRequestName(odcmClass));
513+ string entityWithReferenceRequestName = this.GetEntityWithReferenceRequestName(odcmClass);
514+ return this.GetSelectMethod(this.GetEntityWithReferenceRequestName(odcmClass)) +
515+ Environment.NewLine + Environment.NewLine + " " +
516+ this.GetSelectExpressionMethod(entityWithReferenceRequestName, this.GetEntityNameString(odcmClass));
437517}
438518
439519#>
0 commit comments