unchase / Unchase.Odata.Connectedservice

:scroll: A Visual Studio extension for connecting to OData services with generating client-side C# proxy-classes
Apache License 2.0
44 stars 13 forks source link

BUG: Collections can become empty when updating the same collection. #42

Closed TripleNico closed 4 years ago

TripleNico commented 4 years ago

When i try to update a large class with several collections (large) in it than it can occur when calling .execute that not all collections are updated. If i check in whireshark i can see that the data is there.

For example i call: GET /odata/v1/Customers()?$top=99999&$expand=Orders,BillingAddress,BillingAddress/Country,ShippingAddress,CustomerRoles,Addresses

Wireshark: image

DataServiceQuery: image

If i test it in a loop like:

        For i As Integer = 0 To 9

            dsqCustomers = CType(WebCon.Customers.Expand("Orders").Expand("BillingAddress").Expand("BillingAddress/Country").Expand("ShippingAddress").Expand("CustomerRoles").Expand("Addresses").Take(MaxTop), DataServiceQuery(Of Customer))
            dsqCustomers.Execute()

            For Each item As Customer In dsqCustomers

                If item.Addresses.Count = 0 Then
                    Debug.Print($"{i} = {item.Company} = No addresses")
                End If
            Next
        Next

Then i cannot reproduce it. It seems to occur "random". I know this isn't much and will try to get more debug information, but maybe in te meantime you got an idea what is going wrong?

TripleNico commented 4 years ago

I did some further digging and i manage to narrow it down. It happens when i call two queries that has an expand with the same name of the other query object.

For example: dsqOrders = CType(WebCon.Orders.Expand("Customer").Take(MaxTop), DataServiceQuery(Of Order)) dsqCustomers = CType(WebCon.Customers.Expand("CustomerRoles").Take(MaxTop), DataServiceQuery(Of Customer))

Now i call the execute and convert the response to list: lstOrders = dsqOrders.Execute.ToList lstCustomers = dsqCustomers.Execute.ToList

When i Now loop through the List of Customers and check if Customer.CustomerRoles collection has no item that some of the items in the collection have no items in them and other do. When i check the response with Wireshark i can see (as confirmed in the earlier post) that the data is send. The data is missing in both collections, dsqCustomers and lstCustomers. So it isn't the problem of the .ToList method.

But when i remove .Expand("Customer") from the Orders query than everything works like a charm. It doesn't matter which calling order i use. (first orders then customers or first customers then orders). Hopefully this information helps you?

unchase commented 4 years ago

Hi, @TripleNico

I suppose that the issue is not related to the code generated by the connected service, but to the OData client library used.

Therefore, you should create this issue in this repository.