0
我是新來的MongoDB和寫我的第一EntitySetController訪問我的樣本數據。我的問題是,是否有相當於MongoDB中的導航屬性?我正在嘗試在我的GET方法中使用Include,但沒有任何運氣。這裏是我的代碼到目前爲止:MongoDB的導航性能
Team object :
public class Team
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public string TeamName { get; set; }
public string BadgeSmall { get; set; }
public string BadgeLarge { get; set; }
public string TeamImage { get; set; }
public string Formation { get; set; }
}
Fixture object :
public class Fixture
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public DateTime FixtureDate { get; set; }
[BsonRepresentation(BsonType.ObjectId)]
//foreign key
public string AwayTeamId { get; set; }
//navigation properties
public virtual Team AwayTeam { get; set; }
[BsonRepresentation(BsonType.ObjectId)]
//foreign key
public string HomeTeamId { get; set; }
//navigation properties
public virtual Team HomeTeam { get; set; }
public byte? AwayTeamScore { get; set; }
public byte? HomeTeamScore { get; set; }
public string AwayTeamScorers { get; set; }
public string HomeTeamScorers { get; set; }
}
Fixture controller :
[EnableQuery]
public IQueryable<Fixture> GetFixtures()
{
IQueryable<Fixture> m = mongoDatabase.GetCollection<Fixture>("Fixtures").FindAll().AsQueryable().Include("HomeTeam").Include("AwayTeam");
return m;
}