Created
October 8, 2010 02:55
-
-
Save CoreyKaylor/616303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var order = db.GetCollection<Order>().Find(new { }) | |
.Include(o => o.ProductsOrdered) | |
.First(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Order | |
{ | |
public Order() | |
{ | |
Id = ObjectId.NewObjectId(); | |
} | |
public ObjectId Id { get; set; } | |
public string Name { get; set; } | |
public DbReference<Product>[] ProductsOrdered { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderMap : MongoConfigurationMap | |
{ | |
public OrderMap() | |
{ | |
For<Order>(o => o.ForProperty(p => p.ProductsOrdered) | |
.UseDocument("products")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var order = db.GetCollection<Order>().Find(new { }).First(); | |
var product = order.ProductsOrdered[0].Fetch(() => db); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment