C# 桌面应用程序和 Parse.com [英] C# desktop app and Parse.com

查看:53
本文介绍了C# 桌面应用程序和 Parse.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 C# 编写的桌面应用程序(不是 Windows 8 应用程序),它与 Parse 数据库通信,创建新帐户、登录并将信息传输到用户对象没有问题.

I have a desktop application written in C# (not a windows 8 app) that is talking to the Parse database and there is no problem with creating a new account, logging in and transferring information to the user object.

然而,当涉及到获取这些信息时,这就是问题所在.

However, when it comes to getting that information out,that is where the problem lies.

此代码有效(已编辑)并返回信用值:

This code works (edited) and returns the Credit value:

ParseQuery<ParseObject> query = ParseObject.GetQuery("User");
ParseObject CreditAmount = query.GetAsync("XcaSDFrGGhX");

int Credit = CreditAmount.Get<int>("Credit");

此代码不起作用:

ParseQuery<ParseObject> query = ParseObject.GetQuery("User");
ParseObject CreditAmount = query.GetAsync(ParseUser.CurrentUser.ObjectID);

int Credit = CreditAmount.Get<int>("Credit");

抛出异常:找到具有给定 objectId 的对象.

Parse.ParseException.ErrorCode.ObjectNotFound

提示已找到用户 objectID 但有错误,为什么?

suggesting the user objectID has been found but there is something wrong, Why?

此外,如果 Parse.User 可以声明为全局变量会更有利.这是如何完成的,如在上面的示例中将其声明为 sub 中的本地 Var?

Also, it would be more advantageous if the Parse.User could be declared as a global variable. How is this done as in the example above it's declared as a local Var within the sub?

推荐答案

我不懂 C#,但这是我的看法:

I don't know C#, but this is my take:

在工作代码中,您会得到一个特定的 CreditAmount 对象(实际上是一个 User 对象),它的 objectId 为XcaSDFrGGhX".

On the working code, you get a specific CreditAmount object (which is actually a User object), which has an objectId of "XcaSDFrGGhX".

在第二种情况下,您尝试使用当前用户的 objecId 来查询用户对象.那么,我认为您想要做的是从当前用户那里获取信用"字段?如果是这种情况,您可以直接使用 CurrentUser.ParseUser.CurrentUser 始终可供您使用,并且应该能够通过以下方式获取该属性:

On the second, you try to query for a user object by using the objecId of the current user. So, what I think you are trying to do is to get the "Credit" field from the current user? If that is the case, you can use CurrentUser directly. ParseUser.CurrentUser is always available to you, and should be able to get the property with something like like this:

int Credit = ParseUser.CurrentUser.Get<int>("Credit");

这篇关于C# 桌面应用程序和 Parse.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆