如何在我的 ASP.NET MVC 应用程序中循环访问 ParseObject 集合?
How can I loop through a ParseObject collection in my ASP.NET MVC app?
我正在从我的 Parse 服务器查询对象列表。我想遍历每一个并检索一个值,给定一个键。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Parse;
using System.Diagnostics;
namespace Web.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
Task<int> task = HandleMessagesAsync();
}
private async Task<int> HandleMessagesAsync()
{
var query = ParseObject.GetQuery("Message");
IEnumerable<ParseObject> results = await query.FindAsync();
foreach (var item in results)
{
var text = item.Get<"text">; // Not sure about this syntax
Debug.WriteLine("Result: " + text);
}
throw new NotImplementedException();
}
}
}
根据指南:http://docs.parseplatform.org/dotnet/guide/#retrieving-objects
var text = item.Get<string>("text"); // Retrieve a value from field named "texted" with type "string"
我正在从我的 Parse 服务器查询对象列表。我想遍历每一个并检索一个值,给定一个键。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Parse;
using System.Diagnostics;
namespace Web.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
Task<int> task = HandleMessagesAsync();
}
private async Task<int> HandleMessagesAsync()
{
var query = ParseObject.GetQuery("Message");
IEnumerable<ParseObject> results = await query.FindAsync();
foreach (var item in results)
{
var text = item.Get<"text">; // Not sure about this syntax
Debug.WriteLine("Result: " + text);
}
throw new NotImplementedException();
}
}
}
根据指南:http://docs.parseplatform.org/dotnet/guide/#retrieving-objects
var text = item.Get<string>("text"); // Retrieve a value from field named "texted" with type "string"