locked
$Expand Problem RRS feed

  • Question

  • I me with a problem that the error is "$expand does not support '13' properties expanded simultaneously on the same segment".
    Does that mean the limitation of the properties expanded is 12?
    Thursday, May 21, 2009 8:59 AM

Answers

  • that is correct, there is a System.Data.Services.Internal namespace that contains the ExpandedWrapper classes and the maximum is 12.

    See snippet of code from the namespace. The line you should look at is the last one which is the wrapper that contain 12 expanded properties and after that there is no more.

    namespace System.Data.Services.Internal
    {
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public abstract class ExpandedWrapper<TExpandedElement> : IExpandedResult
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3> : ExpandedWrapper<TExpandedElement>
    
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5> : ExpandedWrapper<TExpandedElement>
    
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8, TProperty9> : ExpandedWrapper<TExpandedElement>
    
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8, TProperty9, TProperty10> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8, TProperty9, TProperty10, TProperty11> : ExpandedWrapper<TExpandedElement>
    }
    


    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, May 21, 2009 11:04 AM

All replies

  • that is correct, there is a System.Data.Services.Internal namespace that contains the ExpandedWrapper classes and the maximum is 12.

    See snippet of code from the namespace. The line you should look at is the last one which is the wrapper that contain 12 expanded properties and after that there is no more.

    namespace System.Data.Services.Internal
    {
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public abstract class ExpandedWrapper<TExpandedElement> : IExpandedResult
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3> : ExpandedWrapper<TExpandedElement>
    
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5> : ExpandedWrapper<TExpandedElement>
    
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace."), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never)]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8, TProperty9> : ExpandedWrapper<TExpandedElement>
    
        [EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8, TProperty9, TProperty10> : ExpandedWrapper<TExpandedElement>
    
        [SuppressMessage("Microsoft.Design", "CA1005", Justification="More than two parameter types used for wide projections."), EditorBrowsable(EditorBrowsableState.Never), SuppressMessage("Microsoft.MSInternal", "CA903", Justification="Type is already under System namespace.")]
        public sealed class ExpandedWrapper<TExpandedElement, TProperty0, TProperty1, TProperty2, TProperty3, TProperty4, TProperty5, TProperty6, TProperty7, TProperty8, TProperty9, TProperty10, TProperty11> : ExpandedWrapper<TExpandedElement>
    }
    


    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, May 21, 2009 11:04 AM
  • Is there any way to add expand more than 12?
    Thursday, May 21, 2009 1:04 PM
  • Unfortunately it is hard coded to twelve so even if you created more ExpandedWrapper's classes the ExpandProvider (BasicExpandProvider class) used in data services would not use them.

    You could implement your own expand provider IF they had exposed the interfaces and base classes used by data services. I could name them but it would not change the fact that there is no easy work around.

    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, May 21, 2009 1:16 PM
  • Thank you very much.
    Thursday, May 21, 2009 1:17 PM
  • I would suggest that you rethink your strategy, step back and and try to think out side of the box what are you trying to achieve and what are the options available to you.

    Just as a note: You could expand the 12 collections and then on separete calls (in batch or not) expand the others that you have then setting the collection properties on the object onthe client side.

    Client myClient = (from c in Context.Clients.Expand("c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12")
                      select c).ToFirstOrDefault();
    
    myClient.c13 = (from c13 in this.Context.c13s
                   where c13.foreignKey == myClient.primarykey
                   select c13).ToList();
    
    // ...
    The example above doesnt use batching.

    Another way would be to use ServiceOperations

    Daniel Portella - http://undocnet.blogspot.com - This posting is provided "AS IS" with no warranties, and confers no rights. If this post is answered your question please mark as the answer and if it is helpful do like wise.
    Thursday, May 21, 2009 1:25 PM
  • That's great! It is useful in some situaition.
    Thursday, May 21, 2009 1:28 PM
  • Is this changed in 4.0?

     

    Thanks,

     

    PV

    Wednesday, June 22, 2011 9:27 PM
  • No, the limit hasn't change in 4.0.

    There are multiple reasons for the limit some of which are here (I'm sure I missed some, and in no particular order):

    - The expanded wrapper classes are generic, so for each combination of expanded types a new .NET type gets created. The bigger the expanded wrapper, the more generic parameters, the more potential types to be created. Since types can't be unloaded this puts more memory pressure on the server.

    - Big number of expansions usually generate really big SQL (or other) queries on the underlying data store. The perf of these is usually not great.

    - Lot of expansions blows up the response size a lot, note that you can limit this even further with configuration options.

    - Having this big of a number in a query usually means that the query is not optimal and that there's very likely a better way for the client to get the necessary data.

    As noted above, I would try to think about my service model design and the client interactions once more to see if I can change the queries. Or use the approach noted above to get the data in multiple consecutive queries (could be done in a batch if the network latency is such a big issue).

    Thanks,


    Vitek Karas [MSFT]
    Thursday, June 23, 2011 7:59 AM
    Moderator