我使用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
我该怎么做?
谢谢。
答案 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;