How can I set the maxItemsInObjectGraph property programmatically from a Silverlight Application?

前端 未结 3 837
悲&欢浪女
悲&欢浪女 2020-12-18 00:17

I have a Silverlight 3.0 application that is using a WCF service to communicate with the database, and when I have large amounts of data being returned from the service meth

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 01:09

    The following is a function that I've used inside a client object that inherits from

    System.ServiceModel.ClientBase(Of IServiceName)
    

    The purpose of the method is to programatically set the MaxItemsInObjectGraph value for each operation. This allows me to have much more complex structures.

        Private Sub IncreaseObjectCount()
            For Each op As System.ServiceModel.Description.OperationDescription In Me.Endpoint.Contract.Operations
                For Each dscob As System.ServiceModel.Description.DataContractSerializerOperationBehavior In op.Behaviors.FindAll(Of System.ServiceModel.Description.DataContractSerializerOperationBehavior)()
                    dcsob.MaxItemsInObjectGraph = Integer.MaxValue
                Next dcsob
            Next op
        End Sub
    

    I usually call it in the constructors of the object.

提交回复
热议问题