Firebase C#更新和删除操作

时间:2017-10-20 14:26:38

标签: c# firebase

我正在开发一个与我们的移动应用程序通信的桌面应用程序。他们使用Firebase作为数据库,但由于Firebase不支持C#,我真的很难过。我可以找到Select& Insert操作的解决方案,但我真的堆叠在更新和删除操作。

   public void recordEntry(Record rec) {
        var json = JsonConvert.SerializeObject(rec);
        var request = WebRequest.CreateHttp("firebaseLink");
        request.Method = "POST";
        request.ContentType = "application/json";
        var buffer = Encoding.UTF8.GetBytes(json);
        request.ContentLength = buffer.Length;
        request.GetRequestStream().Write(buffer, 0, buffer.Length);
        var response = request.GetResponse();
        json = (new StreamReader(response.GetResponseStream())).ReadToEnd();
    }

选择功能的一部分就像:

 public List<RecordUI> FillDataGridView()
    {
        string result = null;
        var request = WebRequest.CreateHttp("firebaseLink");
        request.Method = "GET";
        request.ContentType = "application/json";
        try
        {
            var response = (HttpWebResponse)request.GetResponse();
            Encoding responseEncoding = Encoding.GetEncoding(response.CharacterSet);
            using (StreamReader sr = new StreamReader(response.GetResponseStream(), responseEncoding))
            {
                result = sr.ReadToEnd();
            }
            JObject json = (JObject)JsonConvert.DeserializeObject(result);

我尝试过“request.Method =”DELETE“但它会删除所有数据库。我想我需要一种SQL命令来删除和更新,但不知道如何将其插入到Http请求中。任何想法?

0 个答案:

没有答案