【问题标题】:Can i upload data via c# to firebase?我可以通过 c# 将数据上传到 firebase 吗?
【发布时间】:2021-10-21 13:36:01
【问题描述】:

想要制作一个可以将数据上传到我的 Firestore 数据库的 WPF 应用程序(我必须能够在此集合中制作文档) 这就是我的数据库的样子:https://i.stack.imgur.com/otVFa.png 现在我在想最好的方法是什么,通过 Visual Studio 中的 nuget 扩展或通过 VisualStudio 中的 API。 你能帮帮我吗?

【问题讨论】:

标签: c# firebase google-cloud-platform google-cloud-firestore


【解决方案1】:

我可以通过 c# 将数据上传到 Firebase Firebase 吗?

当然可以。正如@mcy 在他的评论中提到的那样,Firebase 已经提供了一个 C# 客户端库,可以帮助您实现这一目标。为了能够将新文档添加到您现有的“werken”集合中,请使用以下代码行:

Dictionary<string, object> doc = new Dictionary<string, object>
{
    { "description", "Lorem ipsum..." },
    { "description_short", "Lorem ipsum..." },
    { "img", "W3.jpg" },
    { "selable", true },
    { "title", "W3" }
};
DocumentReference addedDocRef = await db.Collection("werken").AddAsync(doc);
Console.WriteLine("Added document with ID: {0}.", addedDocRef.Id);

如您所见,我们让 Cloud Firestore 通过调用 add() 为您自动生成一个 ID。

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2012-08-10
    • 2011-08-05
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多