Returning a single object from OData -.Net

I need to make a request in an OData service that will retrieve a single object, and it should look like this: / EntitySet (par1 = value1, ..., parn = valuen)

However, my query created by LINQ to retrieve the record is as follows: / EntitySet ()? $ filter = (par1 eq value1) and (par2 eq value2) and ... (parn eq valuen)

This, of course, is true. But the server does not allow this. It is consistent only with the first option: with the criteria in parentheses.

Is there something I can do? It would be a shame to manually create a request URL ...

Here is the code:

        var context = new CHART_SRV_Entities(oDataUri);

        var query = context.ApplicationData.Where(ad =>
            ad.institution == "1" &&
            ad.patientId == "2000118" &&
            ad.caseId == "2488");

        DataServiceCollection<ApplicationData> data = new DataServiceCollection<ApplicationData>(context);

        data.LoadCompleted += (s, args) =>
            {
                if (args.Error == null)
                {
                    if (data.Continuation != null)
                    {
                        data.LoadNextPartialSetAsync();
                    }
                    else
                    {
                        var result = data;
                    }
                }
                else
                {
                    MessageBox.Show(args.Error.Message);
                }
            };

        data.LoadAsync(query);

: " " CreateQuery . . , ?

Update2: , , OData. OData, , , Microsoft.

+4
1

. - , . , .

, , .

+2

Source: https://habr.com/ru/post/1546713/


All Articles