Parse.com linq关系查询

时间:2014-03-14 07:55:42

标签: linq parse-platform relational

我使用Xamarin.IOS,我想使用LINQ运行简单的关系查询。我要表。一个表是NewSource,另一个是NewCategory。与名称的两个表关系。例如:

NewSource表格行:

Name: Radikal
Active: true

NewCategory表格行:

NewSourceName: Radikal
Active:true
SportUrl: http://www.something.com
EconomyUrl= http://www.something.com
..
..

我从Parse文档中写了这个查询:

var query= from post in ParseObject.GetQuery("NewSource")
                 where (bool)post["Active"]==true //which mean i want to take only active New Source
             select post;

var query2 = from comment in ParseObject.GetQuery("NewCategory")
            join post in query on comment["NewSourcename"] equals post
            select comment;

var comments = await query.FindAsync();

代码无效。它总是返回null。我哪里可以做错?我想关联两个表连接是NewSource.Name和NewCategory.NewSourceName

我该怎么做?

谢谢。

1 个答案:

答案 0 :(得分:0)

假设NewSource表的Name列与NewSourceName表中的NewCategory列相关联,您可以尝试以这种方式加入它们:

var query2 = from comment in ParseObject.GetQuery("NewCategory")
             join post in query on (string)comment["NewSourcename"] equals (string)post["Name"]
             select comment;