0

I use firebase.database to make query from Firebase in c#, i want to make like Where in linq But i didn't find any extension method that would help. I have CallHistory table has many properties like Rate,Id,Status and make index in Rate property this is json of callhistory

 "CallHistory" : {
    "0798af9c-180c-4d67-a58d-a47043f7e36f" : {
      "CreatedDate" : "0001-01-01T00:00:00Z",
      "Id" : "0798af9c-180c-4d67-a58d-a47043f7e36f",
      "IsActive" : false,
      "IsDeleted" : false,
      "Latitude" : 1.5,
      "ModifiedDate" : "0001-01-01T00:00:00Z",
      "Rate" : 5,
      "RecipientId" : "00000000-0000-0000-0000-000000000000",
      "Status" : 2,
      "StatusDateTime" : "0001-01-01T00:00:00Z",
      "longitude" : 1.2
    },
    "151c7072-0b17-44aa-a834-99c265ef897f" : {
      "CreatedDate" : "0001-01-01T00:00:00Z",
      "Id" : "151c7072-0b17-44aa-a834-99c265ef897f",
      "IsActive" : false,
      "IsDeleted" : false,
      "Latitude" : 1.5,
      "ModifiedDate" : "0001-01-01T00:00:00Z",
      "Rate" : 4,
      "RecipientId" : "00000000-0000-0000-0000-000000000000",
      "Status" : 1,
      "StatusDateTime" : "0001-01-01T00:00:00Z",
      "longitude" : 1.2
     }
    } 

and write this code

           using Firebase.Database;
           using Firebase.Database.Query;

            var firebase = new FirebaseClient("https://sound-project-42ead.firebaseio.com/");
            var calls = await firebase
              .Child("CallHistory").OrderBy("Rate").EqualTo("4")
              .OnceAsync<CallHistory>();

But it doesn;t return any data. With search i found that there are function called OrderByChild() , But i did'nt find this method anymore in firebase.database.query. Is There any other dll can i install it to find orderbychild().

hoda
  • 11
  • 4
  • Please edit your quesetion to include a snippet of the JSON at `CallHistory` (as text, no screenshots please). You can get this by clicking the "Export JSON" link in the overflow menu (⠇) on your [Firebase Database console](https://console.firebase.google.com/project/_/database/data). – Frank van Puffelen Jul 06 '20 at 18:23
  • Done, Thank you for your valuable comment – hoda Jul 06 '20 at 18:44

1 Answers1

0

Firebase Realtime Database queries compare the actual type of the stored data and of the value you specify. And the string "4" is not the same as a numerical value 4.

So you'll want to pass a number:

var firebase = new FirebaseClient("https://sound-project-42ead.firebaseio.com/");
var calls = await firebase
  .Child("CallHistory").OrderBy("Rate").EqualTo(4)
  ...
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I have another question ?? if i want to add more than one query ?How can i do it? – hoda Jul 07 '20 at 00:26
  • Do you mean filter on multiple properties? Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For example, you could have a `"Status_Rate": "1_4"` property. For a longer example of this and other approaches, see my answer here: https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jul 07 '20 at 00:31